Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leaks #3

Closed
MatthieuBarthel opened this issue Jul 15, 2013 · 6 comments
Closed

Memory Leaks #3

MatthieuBarthel opened this issue Jul 15, 2013 · 6 comments

Comments

@MatthieuBarthel
Copy link
Contributor

Hi,

I work on an one page application built on Angular and it uses a lot of maps.

My issue is that every time I instantiate a new map it will consume some memory that won't be released.

I measured the following with Chrome Web Inspector's Timeline: loading a map 100 times made the memory grow from 23MB to 160MB.

The issue is not directly related the angular-gm, but I don't see Google fixing that any time soon. The only fix I imagine is to instantiate a map and reuse it, it means that we need to be able to "rescue" it before Angular destroys the DOM, then "reset" and re-inject it later when another map is called.

Does anybody has that memory issue ?

@dylanfprice
Copy link
Owner

Hi Matthiue,

Thanks for bringing this up. For anyone else who's interested, here's some more info: http://stackoverflow.com/questions/10485582/what-is-the-proper-way-to-destroy-a-map-instance

I can try something similar to your idea and let you know how it goes.

@MatthieuBarthel
Copy link
Contributor Author

Hi dylanfprice,

Thanks for your reply, I worked on it and came up with a proof of concept :
http://plnkr.co/edit/zxhJgOQEhPxPAX9AUCGs?p=preview

The rescue/reuse technique gives good results, tell me what you think and if I can help you for something.

@dylanfprice
Copy link
Owner

Cool thanks for doing that. I will have some time to add this in at the end of this week.

@MatthieuBarthel
Copy link
Contributor Author

That's awesome thanks a lot, I'm looking forward for your release 👍

@dylanfprice
Copy link
Owner

I got your basic idea working and put it in a separate branch: https://github.com/dylanfprice/angular-gm/tree/memory-leak-fix

It's not quite ready yet because I need to deal with a few issues like refreshing stale markers on the map.

I went ahead and put a build of the memory-leak-fix branch up: http://dylanfprice.github.io/angular-gm/angular-gm-0.1.0-memory-leak-fix.js. Let me know if that solves your memory leak and I'll fix those remaining issues!

@MatthieuBarthel
Copy link
Contributor Author

Your are awesome, thank you !

I did an automated memory test, going through 300 views during 5 minutes, each view got a map, and here are the results:

  • master branch : the memory grows up to 280MB
  • memory-leak-fix branch: the memory never go upper then 35MB

Do not hesitate if I can do anything to help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants