Not showing path to GC root in Flash Builder Profiler - actionscript-3

I am trying to use flash builder profiler to find memory leaks in a pretty large flex application. But I see a lot of objects appearing in the memory snapshot for which when I view their object references, I can't see the path to the GC root for them.
I see objects for which it shows "(0 paths)" when expanding but they still weren't garbage collected.
Here is an image from the profiler
Is this a known bug?
I am trying to find out in which cases it doesn't show the path to GC root.

Related

Do I Have a Memory Leak / Garbage Collection Bug?

I'm building an Air application, which, due to the workflow of the animators, needs to load a lot of external swf files.
I load them all via FileStream / Loader Objects at the boot process and then store them in an object for further use.
The instant they get loaded, I use a gotoAndStop(1) command to make them stop looping (the original files have no scripts whatsoever).
After the load process I can see the system memory go slowly but consistently up.
When I manually invoke Garbage Collection with the System.gc() command,
the memory gets cleared again.
If I let the application run for hours it seems the Garbage Collector does not run.
Any ideas what the problem might be? Or should I just forget about it and just occasionally run System.gc() manually?
Thanks a lot!
The Garbage Collector will only run when it needs to, so it is entierly possible that it would go a very long time before running (especially if you have a lot of RAM available).
The important thing is the memory is cleared when it is run. This tells me that you don't have a leak, as it can be cleared up.
Also, how are you measuring the system memory? If you are doing it through Task Manager those numbers aren't really to be relied upon.
I recommend Process Explorer . Monitor the 'Private Bytes' column instead.

AS3 memory leak

I've been working on a library, and have run into a problem with application memory.
I created a class called FileManager which allows the user to call a function called loadNewFiles - this function opens a multi-file selection dialog and stores each FileReferenceList in a vector. I can call the removeList function at any time and remove that list and clear any memory and listeners allocated to that list, so all's well there.
I created another class called UploadManager, which takes an array of FileReference objects and uploads them to a URL via the uploadFiles function. The memory leak appears to be here. When you call this function, it adds the appropriate event listeners and calls the upload function. If the upload fails or the upload is finished, it removes the listeners and clears the vector it has been waiting in.
after the upload manager finishes uploading the files, I call the removeFiles function in FileManager (which, remember, worked perfectly before) and... Nothing happens. The files are removed from both vectors, the listeners are removed from both files, but the memory stays allocated. This obviously has potential to cause problems along the road, as there's no limit to the number of files, uploads, etc. available through the library.
classes:
FileManager
UploadManager
Implementation
It sounds like from your example that the UploadManager still has a reference to the files either from the vector passed into uploadFiles, or some other object in the game still has a reference.
Also note, System.gc() only works on the debug version of the flash player.
So you can't depend on it for an architectural design choice. It works for unit testing memory intensive operations when you need to see the consumption of ActionScript memory "on demand".
In a production product, the ActionScript Virtual Machine is very active in detecting when and where to garbage collect. Most would say it happens right when you don't want it to.
Try profiling the application and looking at the "cumulative instances" vs. "instances", as well as the "cumulative memory" vs. "memory" for the objects in question (i.e. FileReference).
You can force garbage collection during runtime in the Profile View to get a realistic idea of how much memory is actually freed when garbage collection takes place in the Release version.

Why does Flash Builder 4.6 Profiler seem to leak Strings, whereas Debug mode GC's as expected

While unit profiling my classes I noticed that the String class endlessly accumulates (eating up over 90% of the memory in my sizable app). Luckily this is only while running in Profiler mode of Flash Builder 4.6. In debug or deployment (as AIR) memory usage levels off as expected using embedded on-screen memory profilier (Mr Doobs Stats).
To verify I made a test app that was simply a URLLoader continuously loading a text file. When running in Profilier mode using URLLoaderDataFormat.String the String data is never GC'd and grows continuously whereas using URLLoaderDataFormat.BINARY the data is nearly immediately GC'd and stays level.
I hesitate to call this a bug, because possibly it's necessary part of the way the Profilier works… but perhaps this is abnormal for the Profiler? This is the essence of my StackOverflow inquiry.
At any rate, this burned up a couple work-days for me, so if you're Googling wondering why the String class is growing like crazy and never getting GC'd consider measuring your apps memory usage outside the Profilier to verify. In my case I was mislead into thinking I had run into some problem with Master Strings — though it's good understand Master Strings and their impact on memory (see:) don't get mislead like I did.

Way to Log Function Calls in SWF at Runtime?

Is there any way (tool, library, etc.) to log all the actionscript function calls at runtime in a SWF created from Flash Professional? I often inherit projects, and want to more easily analyze and understand their operation. Profiling be nice too.
Logging all calls will probably not help much, because if there are many "small" items involved (i.e. cells in a list, nodes in a tree, particles in a particle engine, enemies in a game, etc. etc.) the log files will clutter up with repetition and soon grow to a size where the sheer amount of information will make learning about the functionality a slow, tedious and painful task.
It is more useful to use a profiler to manage dependencies, memory etc., and use a debugger to step through the code, and/or set breakpoints at interesting points and navigate deeper into the architecture from there.
FDT has a great profiler and debugger. And as a free tool, Monster Debugger is quite good.
You can try Show method entry and Show method exit in SWFWire Debugger. It also offers some profiling. You can also track object creation and destruction, and memory usage.
Disclaimer: I wrote this app

Object tree traversal - afl for app memory leak detection

I am trying to traverse object tree in AFL (adobe flash lite) engine, to check if there are memory leaks in an event driven application (AS3). The idea is to get object tree dump before and after an event processing and check the object tree dump difference for memory leaks.
I believe MMgc is the GC for AFL, I am unable to get a dump of object tree, can anyone help me to point out where in code I can get the alive object info in tamarin.
Have you tried tho profile with FDT, FlashBuilder or FlashDevelop? Or MonsterDebugger?