6
  1. AFAIK android assigns heap limit based on OEM or Screen resolution of device and RAM it self. ex: samsung s5 128mb is limit. How to get current memory usage in android?

  2. Whereas the android Profiler shows that my app is eating more memory than > 128.

OutOfMemory

Line 160185: 12-08 11:22:18.332 I/art     (11728): Alloc partial concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 127MB/128MB, paused 2.012ms total 240.841ms
Line 160325: 12-08 11:22:18.652 I/art     (11728): Clamp target GC heap from 143MB to 128MB
Line 160327: 12-08 11:22:18.652 I/art     (11728): Alloc concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 127MB/128MB, paused 2.378ms total 314.229ms
Line 160675: 12-08 11:22:19.102 I/art     (11728): Clamp target GC heap from 143MB to 128MB
matches the 128mb limit

Queries:

a. Hows to relate Profiler Memory vs Java API heap memory used?

b. Is it Profiler java memory == Java API heap memory used as above #1.

c. How to relate Profiler Memory vs Java API heap memory used vs Device settings memory usage by an app?

d. Is it possible to know JavaScript(Cordova based webview app), native level heap usage?

Thanks

Nithin

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
NitZRobotKoder
  • 1,046
  • 8
  • 44
  • 74
  • 1
    a-c : They are related. They are the same. The profiler shows the heap memory used. If you use there more and more (heap) memory, your app will eventually crash with OutOfMemoryException. d. No idea. Never used it. – android developer Dec 12 '17 at 08:38
  • @android developer https://developer.android.com/studio/profile/memory-profiler.html#how-counted so java api and profiler java is same (b). OOM is because java allocation failed. JavaScript and native is memory is not accounted. isnt? – NitZRobotKoder Dec 12 '17 at 08:43
  • 1
    Since Javascript is called on WebView, it uses the native memory. You have a huge amount of memory compared to the heap memory. Sadly, as I wrote, I didn't use it often enough to tell you how much native memory the app uses. – android developer Dec 12 '17 at 08:46
  • @androiddeveloper https://developer.android.com/reference/android/webkit/WebView.html WebView is java object this memory will be accounted to java heap isnt? – NitZRobotKoder Dec 12 '17 at 08:58
  • 1
    Most of WebView memory is native memory (can reach a lot, BTW). Everything you use on Android must be, in one way or another, be wrapped by Java code. You have an Activity to show content. It doesn't mean it can't hold classes that use native memory within it. – android developer Dec 12 '17 at 10:07
  • I suggest to use normal UI over using WebView, BTW. It is much more optimized and fluid, and has better look&feel. – android developer Dec 12 '17 at 10:09
  • @androiddeveloper yeah but we chose it for cross platform support! – NitZRobotKoder Dec 12 '17 at 11:06
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/161014/discussion-between-nitzrobotkoder-and-android-developer). – NitZRobotKoder Dec 12 '17 at 11:07

0 Answers0