what is the difference between dalvik heap and native heap in android? which one is fixed.?
Asked Answered
D

1

7

I guess Dalvik heap is fixed for android app. like 64MB, 96MB etc.

is it right ?.

If so, is native heap is also fixed to some size ? or will grow depending on the app usage?

can anyone please help me out? thanks.

Delicate answered 12/6, 2014 at 12:53 Comment(0)
P
5

I guess Dalvik heap is fixed for android app. like 64MB, 96MB etc.
Is it right?.

Android proposes a particular value for apps as the limit based on the Android Version (getMemoryClass() API of the class ActivityManager will give you the value for the device your code is running on), but vendors tweak it to increase it by a margin that suits their requirements (for e.g. in the case of hardware supporting higher screen resolutions as larger resolutions will use larger bitmaps).

If so, is native heap is also fixed to some size ? or will grow depending on the app usage?

Yes, there is no hard limit as it grows depending on the usage. You can use as much memory as the device has available (i.e. Total memory - memory used by other programs). When Android thinks that it's getting low on memory, then based on many factors (whether or not it's in the foreground, or providing services to some foreground app), it'll start killing processes. You can get more info about the device's memory using android.app.ActivityManager.MemoryInfo. Also since Android 3.0, apps can request a larger heap (Although, one should avoid it until and unless its completely unavoidable). You can increase the heap size by using android:largeheap="true" in your manifest file

Photographic answered 12/8, 2014 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.