garbage-collection

What happens when a Scala "Future" is garbage collected?

Say I have a Stream that's rather expensive to compute. I can easily create a thread that "computes ahead" just by writing something like import scala.actors.Futures._ val s = future { stream.size } If I then throw away the reference to this Future, will that thread be killed off by the garbage collector? ...

How do I find the base address and size of the stack on MacOS X?

I'm porting an imprecise garbage collector from Windows to MacOS X. In it, it has to scan the stack to identify potential pointers into the heap, and then use those as GC roots. To do this, I need the stack's base as well as it's length. In Windows, this code uses an algorithm similar to what's described here: http://stackoverflow.com/...

Objective-C: Do you have to dealloc property objects before deallocating the parent object?

Let's say I have an object named "foo" with another object named "bar" as property. When "foo" deallocates, will it automatically remove all references to "bar" so that "bar" deallocates as well? or will "foo" deallocate and "bar" float in memory somewhere? even if all of "bar"'s references are defined in "foo". thanks in advance. ...

What best practices for cleaning up event handler references?

Often I find myself writing code like this: if (Session != null) { Session.KillAllProcesses(); Session.AllUnitsReady -= Session_AllUnitsReady; Session.AllUnitsResultsPublished -= Session_AllUnitsResultsPublished; Session.UnitFailed -= Session_UnitFailed; Session...

Does List<T> create garbage in C# in foreach

Correct me if im wrong but doing a foreaver an IEnumerable<T> creates garbage no matter what T is. But I'm wondering if you have a List<T> where T is Entity. Then say there is a derived class in the list like Entity2D. Will it have to create a new enumerator for each derived class? Therefore creating garbage? Also does having an interf...

How to reduce Garbage Collection performance Overhead

MY application profiling showing a big Garbage Collection overhead. The profiler does'nt have a drill down into the Garbage Collection. What should I do to reduce this overhead? I have many short-living arraylists and some long-lived that only die when the application shuts down. ...

Track down memory leak in Ruby 1.9

I have a Ruby application that uses eventmachine and starts 16 processes that each manage 1000 connections. Initially each process only uses around 150MB, however after some runtime they consume more and more towards 500MB and I am running out of memory and swap. The amount of open connections (indicated by EM.connection_count) is normal...

Relative Performance of Java's Garbage First (G1) Garbage Collector?

Does anyone know of any performance benchmarks of Java's new Garbage First (G1) Garbage Collector (as compared to the "old" GCs)? In terms of GC pause times, Sun states that G1 is sometimes better and sometimes worse than CMS. While the G1 collector is successful at limiting total pause time, it's still only a soft real-time collector....

What's the better option for anonymous event listeners?

I'm trying to figure out the best option to use anonymous event listeners that are 100% garbage collected after use. I got these two examples but I'm wondering if it actually makes any difference between them ... var listener1:Function = function(e:Event):void { resource.removeEventListener(e.type, listener1); loadedHandler(resource);...

Interview question: Objects eligible for garbage collection

Give the following code: class A { Boolean b; A easyMethod(A a){ a = null; return a; } public static void main(String [] args){ A a1 = new A(); A a2 = new A(); A a3 = new A(); a3 = a1.easyMethod(a2); a1 = null; // Some other code } } The question is h...

using static dictionary as cache may lead to leak problem ?

hello all, I have memory leak in the web application (servlet) that I am working on. I am suspicious of 1 cause and wanted to hear your ideas about it. I use hashmaps,hashsets etc. as DB (about 20MB data loaded). These maps,sets get reloaded once in every 10 min. There are huge amount of simultaneous requests. I read that, GC passes ob...

Android - Activity Constructor vs onCreate

I understand that Android Activities have specific lifecycles and that onCreate should be overridden and used for initialization, but what exactly happens in the constructor? Are there any cases when you could/should override the Activity constructor as well, or should you never touch it? I'm assuming that the constructor should never b...

Java Interview Question: finalize() method

I was given the following phrase in an interview: The invocation of an Object's finalize() method is the last thing that happens before an object is garbaged collected. I had to answer by: True False I've chosen True but it was wrong. Can you please explain me why ? ...

How to implement the MVC pattern without keeping Views alive

I'd like to implement the MVC pattern in a difficult situation. The difficulty is that my Models (the entities generating the events) are long-lived, while the Views (the receivers of the events) are short-lived. My problem is that through the connection between the two, the long-lived Models keep my short lived Views alive, i.e. they ca...

Why does this memory not get cleaned up, or get allocated at all?

So, I've got this awesome program that is very useful: static void Main(string[] args) { new Dictionary<int,int>(10000000); while (true) { System.Threading.Thread.Sleep(1000); } } This doesn't even produce any warnings from the compiler, which is surprising. Running this allocates a chunk of memory. If I run ...

Java garbage collection

I have created an object in Java, Named FOO. FOO contains a large amount of data.. I don't know say for a ten mega byte text file that I have pulled into ram for manipulation.(This is just an example) This is clearly a huge amount of space and I want to deallocate it from memory. I set FOO to NULL. Will this free up that space in me...

The various options for solving PermGen problems

Hi I am looking into the various options around garbage collection on a Java 6 18 VM and would like some pointers. We run our application on JBoss, and occasionally there are the infamous PermGen errors during redeploys. There is a lot of conflicting and obsolete information on the internet about the best way to solve or mitigate this ...

Inner workings of the .NET garbage collector?

I've read detailed papers about the inner workings of the various garbage collectors in the JVM, but I've had trouble finding the same level of details for .NET's runtime... Anyone have links to good articles/research/pages on .NET's garbage collector? ...

GC and memory limit issues with R

I am using R on some relatively big data and am hitting some memory issues. This is on Linux. I have significantly less data than the available memory on the system so it's an issue of managing transient allocation. When I run gc(), I get the following listing used (Mb) gc trigger (Mb) max used (Mb) Ncells 21471...

PHP session garbage collection becoming an annoyance, i need some help to modify this behavior.

I have been having this problem for some time now, I dont exactly know that if this is the issue but I am pretty confident that it is, I have my remember me session set too expire after 1 week, but when I go to my site after a few hours of inactivity my remember me session is gone, i check my servers tmp dir and the session flat file is ...