GC is lazy/opportunistic and doesn’t always collect everything.

If you have time read the various posts on my blog dealing with memory leaks 
and memory management.

--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui


On 5/26/10 4:46 PM, "rinogo2" <warpr...@warproof.com> wrote:






Hi, all!

I've noticed some odd behavior with my flex/flash applications - it seems that 
as program execution continues, the flash runtime requires increasingly more 
memory, even if memory leaks are theoretically eliminated.

An example in one of my applications can be observed here:

http://featurific.com/files/tmp/flashLazyGc.jpg

The yellow line in this image tracks the memory usage of my program.  As you 
can see, at the time of this screenshot, 10 minutes of execution have elapsed 
and the VM is using ~443 Mb of memory*.

(*Note that in this instance, my program was running a 'stress test' designed 
to push the VM and my application to its limits - normal execution isn't nearly 
as memory/processor intensive)

As you can see in this image, the program starts out on the right side of the 
graph with a very small memory footprint.  Memory used steadily increases with 
long periods of overall consistency.  However, eventually, around what must be 
about 8:00 into the test, the memory usage drops significantly and then starts 
to climb again.

Its this final drop and the long periods of overall consistency that make me 
curious.  These characteristics seem to suggest that the memory usage of my 
program is not necessarily increasing due to memory leaks, but according to 
Flash's whims.  In my experience, memory leaks are usually accompanied by a 
*steady*, *unreversing* upward trend in memory usage.  However, in this 
scenario, memory usuage increases inconsistently and even drops (around 8 
minutes in the graph).

This brings me to my question - is this normal for the Flash VM?  My best guess 
for what is happening is that Flash is determining that my program is making 
many requests for memory, and that this memory is readily available (I'm 
developing with 8GB RAM).  So, it allocates memory according to my program's 
requests, and is lazy about freeing this memory when it is no longer in use 
(since memory seems to be abundant on my system).

This seems like a strange way to implement a VM, but then again, I've never 
written a garbage collector, so I'm obviously unqualified.  What do you all 
think is going on here?

Thanks so much in advance!
-Rich






Reply via email to