Mobile Web Cat Memory Consumption

We are working on an HTML5 application for mobile devices (Android + iOS). But the big problem is memory consumption - the amount of used memory grows very quickly, and the application becomes breaking.

What are the best practices, tips, tools, solutions, etc. to deal with memory leaks in HTML (JavaScript) applications?

PS We focus only on Webkit browsers

+8
javascript android ios webkit
source share
2 answers

Recently, there have been very interesting articles on this topic. There are some really amazing sources of creating objects that don't attract attention if you aren’t attuned to it. As a rule, the problem is not in the use of memory, but in fact the garbage collection cycles necessary to collect memory, the application flows slowly.

This article is the best I've read on the topic recently: http://www.scirra.com/blog/76/how-to-write-low-garbage-real-time-javascript

As for tools to combat / diagnose the problem, Google Chrome Speedtracer comes to mind. Of course, customization for Chrome does not guarantee customization for all browsers, but most of the things that cause objects to be created in Chrome are common to the JS specification, as it is implemented by all browsers.

It is important to remember that the use of RAM and the use of video memory do not match. One of the best practices is to determine which parts of your user interface will be hardware accelerated, and make sure they are small (that is, they fit on the screen all at once). If you have huge parts of the hardware acceleration of the screen scroll, you will get tears / GPU tiling and scrolling. You can partially discover this with the iOS simulator. This article briefly discusses the idea: http://devinsheaven.com/turn-your-iphone-wacky-and-make-your-iphone-application-better/

Finally, in JavaScript, there are a bunch of really common memory errors that every engineer comes across from time to time. IBM has a good list. I can’t post more than two links because I am n00b, but you can google for “Common JavaScript Memory Leaks”, and this is probably the first result.

+7
source share

Some other diagnostic tools that may be useful in Chrome are the task manager, the timeline panel, and the curator profile.

Browser - Chrome Canary (27.0.1447.3 canary)

  • Task Manager: go to Tools → Task Manager // Right-click the header tab and check "JavaScript memory"

  • Timeline tab: Tools → Developer Tools → Timeline // Click Record, do some interaction, and then stop recording

  • Heap Profiler: Tools → Developer Tools → Profiles // Click Heap Snapshot

  • Remote debugging

  • Deep Memory Profiler

"3 snapshot" // Presentation "Troubleshooting memory leaks in Gmail"

+3
source share

All Articles