-
Notifications
You must be signed in to change notification settings - Fork 195
Description
After reading #43, something said by RASMiranda worried me:
you could refresh the entire map by emptying the appropriate DIV container and calling again $.mapael()with the new options
I tried exactly this with ajax, but don't know if it's because of my map, but after the first 5 updates page starts getting slow and the browser not responding...
Holly cow, that is typically a leaking problem!
New map test
I made a script to test it:
Every seconds:
- Empty mapcontainer
- Replace mapcontainer content with initial HTML (.map and .myLegend divs)
- Create Mapael on it
Here is a screenshot of Chrome debugger for 10 iterations:
We can see the 10 occurences through the number of listeners (in orange). They represents the number of events attached to elements on the page. They drop after calling $.empty() because jQuery take care of removing all event handlers.
Now let's check the number of nodes (in green). This is the number of DOM nodes retained in memory. And as you can see, it is always increasing after each call to Mapael! And even after forcing the GC => note the JS heap (blue line) drop at the end, but not the number of nodes.
Here is a leak!
This is why after a while the page starts getting slow and not responsive.
Updated links test
I made a script to test the update of links (links creation and removal):
- Create Mapael on mapcontainer with some initial plots/links
Every seconds: - Trigger update: delete all plots/links (with
deletedPlots = "all"and such) - 500ms timeout: Trigger update: add some new plots/links
Here is what we got:
The number of nodes and listeners are always increasing, and forcing a GC (blue line drop at the end) doesn't reduce this number.
This is bad. With more plots/links, this will lead to a page more and more slow.
Updated legends test
I made a script to test the update of legends (legend replacement, implemented through #87):
- Create Mapael on mapcontainer with an initial legend
Every seconds: - Trigger update: set a new legend
We have this:
Wow! At last, something is not leaking.
The number of nodes are increasing, but when forcing GC (at the end), it will drop to the initial one.
This is good. Updating the legend will not lead to a leaking problem.
Now, what to do?
I have some ideas to correct the leaking. I will submit some PR and we will be able to discuss it.
Also, I want to submit the code for the test scripts I used. They are modified version of existing example, with loops and such. Do you think I can create a test directory and put these files in it?


