[ka-Map-users] Memory leaks in kaXmlOverlay?
Paul Spencer
pspencer at dmsolutions.ca
Fri May 5 07:39:12 EDT 2006
Pg,
from what I understand of browsers, they do garbage collection
automatically and there is no way to influence the process.
The biggest source of memory leaks seems to be something called a
closure. A closure is the two-way binding of a DOM element to a
javascript object. This means that a javascript object has a
reference to a DOM element and the DOM element has a reference to the
javascript object. Sometimes this circular reference can be nested
quite deeply.
This seems to affect IE primarily, FireFox has done a much better job
of cleaning up dead objects that only refer to other dead objects.
Google Maps API has some hints on dealing with closures, with some
external links.
http://www.google.com/apis/maps/documentation/#Memory_Leaks
The biggest cause of this is in event handling on DOM elements,
apparently.
Adding/removing stuff dynamically should ensure that any object
removed from the DOM has all event handlers 'null'd and that the
objects removed should have any references to DOM elements null'd as
well.
Cheers
Paul
On 5-May-06, at 6:49 AM, Pg wrote:
> I agree with Lorenzo, kaXmlOverlay is just poor code I wrote to make
> "demo" applications, but waiting for a better implementation I think
> should be usefull to make it working better.
>
> I suspect there are memory leacks (at least in IE), but I'm not so
> expert in JavaScript
> to correctly manage memory allocation.
>
> I use a Java-like coding stile (I delete all references to a variable
> and I expect the garbage collector do its job) with some C++ like
> instructions (e.g. in removePoint I do a delete this.ovrObjects[i];).
>
>
> Should I use the operator delete on all objects?
> When I call kaMap.kaMap.removeObject should I do other operation on
> the
> div and its contents?
>
> I'think the garbage colection process in browsers is triggered by a
> page
> [re]load. Is there a way to start gc in the code?
>
> How should I delete the DOM objects (div, img, canvas, etc.)?
>
>
> Could I ask you how to use Venkman debugger to monitor memory?
>
> -Pg
>
> 2006/5/4, Lorenzo Becchi <lorenzo at ominiverdi.com>:
>> To be onest I think that kaXmlOverlay is not mature yet.
>> PG has done a great work but you cannot use kaXmlOverlay for public
>> appications.
>>
>
>
> 2006/5/4, Justin George <justin.george at gmail.com>:
>> Hi there, I'm a relatively new user of ka-map. The XML overlay is
>> working beautifully, I'm refreshing the overlay on extent change to
>> display the polygon of interest at the center of the map, eg,
>> counties, cities, etc.
>>
>> My problem is that kaXmlOverlay's removePoint method seems to remove
>> the point from visibility, but not delete it entirely. I may be
>> mistaken, however, it appears to run more and more slowly as time
>> goes
>> by in a session. I believe what I'm seeing in Venkman debugger
>> confirms.
>>
>> Anyone have confirmation or ideas for a fix for this?
>>
>> Code: (in startup.js)
>>
>> in myOnLoad():
>> myKaOverlay = new kaXmlOverlay(myKaMap, 5000);
>>
>> in updateLinkToView():
>> myKaOverlay.removePoint();
>> myKaOverlay.loadXml('polygon.php?long=' + cx +'&lat=' + cy);
>>
>> Thanks
>> J
>>
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
+-----------------------------------------------------------------+
|Paul Spencer pspencer at dmsolutions.ca |
+-----------------------------------------------------------------+
|Applications & Software Development |
|DM Solutions Group Inc http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+
More information about the ka-Map-users
mailing list