How can I find memory leaks in a single page javascript application?

The application is a single page, so it is not updated, and we hope that it will work on the Android device for a long time.

We are currently seeing a crash (and a logcat report indicating an OOM error on startup on Android) after about 18 hours. When I use remote debugging and fix the timeline using the chrome dev tools, it is very obvious that we have a memory leak, because we see a steadily growing bunch of js. It seems like the heap continues to grow until I force the garbage collection.

Another thing that seems special to me is that on the timeline, I also see that our event listeners are growing and not affected by the forced GC. Could this be a problem in itself? (We are talking about 10 thousand listeners according to the timeline)

Does anyone have any recommendations that go beyond the standard β€œ3-way snapshot analysis methods”? This is not very useful, because the heap grows even when it does not interact, and I believe that this is due to some periodic updates that we do behind the scenes to read and display data. Otherwise, I am completely open to any other memory analysis tools.

I have very little experience in this area, so any advice on narrowing down the cause of these unpleasant leaks will be awesome!

, - . .

EDIT: , , dev tools , , ... ?

+4
1

. , - , . while (true), -. vars , javascript GC .

? while (true) . 1 -, - javascripts.

, javascript GC () . - ?

+2

Source: https://habr.com/ru/post/1599183/


All Articles