Object tree traversal - afl for app memory leak detection - actionscript-3

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?

Related

Not showing path to GC root in Flash Builder Profiler

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.

Memory Leak, SignalR in realtime webapplication

My application connects to a SignalR-hub, and it receives about 15 json-files per minute. For every json-file with a geolocation, a marker gets placed on a sphere in the 3D WebGL-scene, and gets stored in an object {}. When the objectlist reaches 100 items, the application deletes the first item in the objectlist, and deletes the corresponding marker from the scene.
But still, there is a huge memory leak, and when I hit about 200 events, the application crash.
Are the json-files being stored somewhere, and are causing the memory leak?
Though this is not the solution, but I will suggest you to use Ants Profiler to see if there is any memory leak issues in your application.
I will suggest you to derefernce all the listitem in the generic list after it is no use. This is the major cause of memory leaking.
Beware of concatenating strings, use stringbuilder as much as possible.
I am working on the same issue. I had no memory leaks before implementing signalr and now have a fairly significant one. I can disable the signalr in my app and the leak goes away. I'm on version 2.2.0 of signalr (the most current version from Nuget. The only thing that could be hanging up in memory from my code point of view is the event handler. At least that's the only thing I'm creating on the client side.

Understanding 'Native Memory profiling' in Chrome developer tools

I am building an application with a simple search panel with few search attributes and a result panel. In the result panel, I am rendering the data in a tabular form using Slickgrid.
After few searches (AJAX call to server), the page gets so much loaded and it eventually crashes after sometime. I have checked the DOM count and the JavaScript heap usage for possible memory leaks. I couldn't find anything wrong there. However, when I ran the experimental native memory profiler, I see that the "JavaScript external resource" section uses 600+ MB memory. On running the garbage collector, it is getting down to few MBs. I have couple of questions here:
What contributes to the "JavaScript external resource" section? I thought it corresponds to the JSON data / JavaScript sources which gets transferred from the server. FYI, the gzipped JSON response from the server is ~1MB.
Why is Chrome not releasing the memory pro-actively instead of crashing the page? Again, when I manually run the garbage collector, it is releasing the memory used by "JavaScript external resources".
How do I fix the original problem?
JS Heap Profiler makes a snapshot of the objects in the javascript but javascript code may use native memory with help of "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array" and "Float64Array".
So when you take a snapshot it will have only small wrappers that point to native memory blocks.
Unfortunately heap snapshot does not provide data about the native memory that was used for these kind of objects.
Native heap snapshot is able to count that memory and now we know that the page uses native memory via an array or via an external string.
I'd like to know how did you check that the page has no memory leaks? Did you use three snapshot technique or just checked particular objects?
Tool to track down JavaScript memory leak

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.

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