Cyclic referals, XML Objects = Memory leaks!
Yes today while working on an html page that had a ASP.Net tree component I noticed something rather odd. In the task manager (watching the IEXPLORER’s memory usage) the memory was jumping from 1-3 Mb with each node expand. It was reqesting new sub node data from an xml source. This is powered by Javascript. I later found that there is a memory leak in InternetExplorer 4 and onwards with this.
Cyclic Referals:
This is where object A refers or uses an property of Object B >> Object B uses a property of Object C >> Object C refers to a propety of Object A.
When this happens in Javascript the Garabage Manager canot delte any of these Objects. Even on when navigating to a completely new site. The only way to free the memory was to shut IE. Now I managed, using my large noded tree to get memory useage to over 170 Mb in a few minutes! You cant even delete the objects manually.
So thinking this was bad I wondered what would happen in Flash and sure enough it happens there to. Now where this comes into play is if your refering to an Xml object in flash. Xml in Flash 8 player has come a long way!!. So has memory management. And thank the big one so has the performance of the whole player. But it still has a large toll on the system. Especially if you creating new nodes and adding them to another xml object. There are many pit falls. I have an application that I am involved in that runns 24/7 and it has become ever increasingly memory hungery and can crash the machine. I didnt write the source only now maintain it and I am left with the fact that for memory management I may have to rewrite large amounts of it. Basically if you are creating indual nodes make sure you destroy the object afterwards. Same for XML objects. And really for all objects that are no longer in use.
I checked out Goowy (Great Flash based email client) to see what happened there as I have noticed before that when in Firefox and left open for a while, ie. the course of the day, that my computer can really chug up. I think I found a similar problem there to. (have advised them of it and they are looking at it>>Cheers Alex).
I think its time for some tests, but really what this comes down to is good programming practices and as some advise for flashers, check out "head first design patterns". Its cheap enough on Amazon and really helps the pre programming design.
Stay tuned for how I go solving my memory problems in Javascript and flash. One colleg sugested I wrap all 3 objects A, B, C, in another object and delete that. Time will tell.




No comments yet. Be the first to comment this post.