Android Profiler vs Java API level memory calculation
Asked Answered
R

0

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

React answered 8/12, 2017 at 12:40 Comment(8)
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.Kumler
@android developer developer.android.com/studio/profile/… so java api and profiler java is same (b). OOM is because java allocation failed. JavaScript and native is memory is not accounted. isnt?React
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.Kumler
@androiddeveloper developer.android.com/reference/android/webkit/WebView.html WebView is java object this memory will be accounted to java heap isnt?React
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.Kumler
I suggest to use normal UI over using WebView, BTW. It is much more optimized and fluid, and has better look&feel.Kumler
@androiddeveloper yeah but we chose it for cross platform support!React
Let us continue this discussion in chat.React

© 2022 - 2024 — McMap. All rights reserved.