Internet Explorer memory leak with a simple example

172 views
Skip to first unread message

Canam Group

unread,
Dec 3, 2010, 10:41:32 AM12/3/10
to google-map...@googlegroups.com
Hi,

I'm migrating my map application from V2 to V3.
I'm now done... and everything works fine with Firefox.

I wanted to try with IE, it works well, but it ends up taking all the RAM on the computer.

Since my map application is quite complex, I tried to create a very simple map to demonstrate this issue. I'm using setInterval to update marker position every 10 minutes in my prod. application, but I update every 10 seconds in my little example here:
http://www.canamgroup.ws/GM.nsf/Map4?OpenPage

I just kept open this map for 30 minutes, and RAM went from ~60 megs to ~500 megs in IE !!
As soon as I go to another page (or obviously close the browser), the RAM decrease normally.

With Firefox, It went from ~50 megs to ~65 megs (it kept increasing and decreasing after each refresh).

In V2, we had to use "GUnload()" to avoid memory issues.  Is there something special I must do in V3?
I read the documentation thoroughly and I thought I was doing all the right things (.setMap(null) and empty my array) as explained here:
http://code.google.com/apis/maps/documentation/javascript/overlays.html#RemovingOverlays

Can someone help?
Thanks!

Canam Group

unread,
Dec 6, 2010, 11:33:34 AM12/6/10
to google-map...@googlegroups.com
Nobody has experienced this?

bratliff

unread,
Dec 6, 2010, 12:57:24 PM12/6/10
to Google Maps JavaScript API v3
> right things (.setMap(null) and empty my array) as explained here:http://code.google.com/apis/maps/documentation/javascript/overlays.ht...
>
> Can someone help?
> Thanks!

Try using "setTimeout" instead of "setInterval". If your computer
cannot service interrupts quickly enough, you may be producing a flood
of interrupts.

For a simple example, see:

http://www.polylib.us/polycluster/fixleak

CPU speed determines the pace. It is also a good idea to use
"clearTimeout" or "clearInterval" to discard unserviced interrupts.

bratliff

unread,
Dec 6, 2010, 1:40:42 PM12/6/10
to Google Maps JavaScript API v3
Also, if you are running multiple tasks on a slow single core CPU, the
forground task will receive more CPU cycles than the various
background tasks. Your CPU may be fast enough to keep pace with your
application in the forground but not in the background.

Canam Group

unread,
Dec 6, 2010, 3:43:36 PM12/6/10
to google-map...@googlegroups.com
Hi bratliff,

Thanks for your answer.

I tried to use "setTimeout" instead of "setInterval" (with "clearTimeout") and I still experience a memory leak in IE.
Here's an updated example:
http://www.canamgroup.ws/GM.nsf/Map4b?OpenPage

I'm doing my tests on my computer, which is a brand new quad core computer.
It does the same memory leak on coworkers' computers as well... but only with IE... never with Firefox.

Just keep open the page at the URL above for like 15-20 minutes and you'll see how fast IE grabs all the RAM (and never releases it).
Do you have any other ideas?

Thanks again!

bratliff

unread,
Dec 7, 2010, 12:41:02 PM12/7/10
to Google Maps JavaScript API v3
It looks like you are not clearing your "click" event listeners. Each
cycle adds another "click" event listener to the marker.

I would let Google do the "clearOverlays" work for you in case the API
has to clean up its own references. I would use a new overlaysArray
rather than reuse the old overlaysArray. It will give the garbage
collector a chance to clean up remaining references. Internet
Explorer is known to have difficulty unwinding circular references.

Canam Group

unread,
Dec 7, 2010, 2:47:29 PM12/7/10
to google-map...@googlegroups.com
"It looks like you are not clearing your "click" event listeners. Each cycle adds another "click" event listener to the marker."

- I thought that could be the issue too... but even If I totally remove the "click" event listeners, IE is still taking more and more memory:
http://www.canamgroup.ws/GM.nsf/Map4d?OpenPage

I thought that by removing the markers from the map (.setMap(null) and empty my array), all event listeners would be cleared.  I read this here:
http://www.mail-archive.com/google-map...@googlegroups.com/msg04733.html


"I would let Google do the "clearOverlays" work for you in case the API has to clean up its own references."

- What do you mean by that?  I'm not sure I understand how to do that?


" I would use a new overlaysArray rather than reuse the old overlaysArray. It will give the garbage collector a chance to clean up remaining references."

- I'll try this and get back to you.

Thanks a lot for your help, I really appreciated.

Canam Group

unread,
Dec 7, 2010, 2:56:30 PM12/7/10
to google-map...@googlegroups.com
I tried to create a new overlaysArray each time:
http://www.canamgroup.ws/GM.nsf/Map4e?OpenPage

Is this what you meant?
Unfortunately, memory is still leaking in IE.

Thanks again!

Pil

unread,
Dec 8, 2010, 3:01:03 AM12/8/10
to Google Maps JavaScript API v3
What if you try

clearInstanceListeners(all_old_markers)

in a loop before loading a new cycle?

Canam Group

unread,
Dec 8, 2010, 8:50:25 AM12/8/10
to google-map...@googlegroups.com
Hi Pil,

I have the memory issue even if I'm not adding any event listeners to my markers... like here:
http://www.canamgroup.ws/GM.nsf/Map4d?OpenPage

I did try your suggestion here:
http://www.canamgroup.ws/GM.nsf/Map4g?OpenPage

Unfortunately, I'm experiencing the same problem.
Am I doing something wrong?

Thanks for your help!

Pil

unread,
Dec 8, 2010, 10:08:44 AM12/8/10
to Google Maps JavaScript API v3


On Dec 8, 2:50 pm, Canam Group <canamgr...@gmail.com> wrote:

> Unfortunately, I'm experiencing the same problem.
> Am I doing something wrong?

Don't think so. v3 marker seems even more heavier than v2 marker.
You can try to set clickable: false and flat: true as Ben suggested
here for a 'sluggishness' problem.

http://groups.google.com/group/google-maps-js-api-v3/msg/7713ff30039b5a54

If this doesn't solve the problem I'd try something with Fast-marker

http://multimarker.googlecode.com/svn/trunk/fast-marker-overlay/maps-v3/example/

Canam Group

unread,
Dec 9, 2010, 9:27:23 AM12/9/10
to google-map...@googlegroups.com
"You can try to set clickable: false and flat: true as Ben suggested here for a 'sluggishness' problem."

- In my real application, I need my marker to be clickable. I can remove the shadow, but that doesn't prevent IE from leaking memory.

I'll take a look at Fast-marker.

Thanks!

Ben Booth

unread,
Jan 19, 2016, 10:42:13 PM1/19/16
to Google Maps JavaScript API v3
Sorry to revive a 5 year old conversation but did you ever resolve this? We also have a reasonably complex mapping application that is leaking memory in IE. The JavaScript heap never appears to increase or decrease substantially (looks like normal garbage collection behaviour) but the system memory used by the IE tab creeps up every refresh.

Users of our application have reported it getting slower and eventually crashing when leaving a tab open for a long time, we haven't found any solutions yet. Finding this thread leads me to think that it's possibly something that started when we upgraded to maps API v3 a few years ago.

Thanks for any help...
Reply all
Reply to author
Forward
0 new messages