开发者

Quick check on the heap?

开发者 https://www.devze.com 2023-03-10 04:22 出处:网络
I have a rooted Evo as a test device. Now I have been testing my app on it all the time and lately (relatively) I have had constant memory leaks or over assignment. So on a whim, I decided to test it

I have a rooted Evo as a test device. Now I have been testing my app on it all the time and lately (relatively) I have had constant memory leaks or over assignment. So on a whim, I decided to test it on a tablet I have at work. The app ran fine. Not even a hint of memory issues. So I begin to wonder if in rooting my device my heap size has been fubared? Part of my suspicion comes from this line when the app crashes on my Evo. Now, if this line can be trusted, this is way off. I thought that the heap (at the very minimum) was 16MB --- 24MB for my 2.2 Evo.

dalvikvm  E  Out of memory: Heap Size=4803KB, Allocated=2452KB, Bitmap Size=19002KB

So my question is: Is there a way to find the actual a开发者_开发问答llowed heap size on my phone? Any way to modify it?

TFYT ~Aedon


To get the actual allowed heap on your phone you can use http://developer.android.com/reference/android/app/ActivityManager.html#getMemoryClass() which will return an integer representing the amount of MB that is the max heap per application.

And you cannot change this as a developer of an app (You can change the max heap for a device you own though). However, if you are targeting API Level 11 (Honeycomb), you can put android:largeHeap="true" in your manifest file, and then call http://developer.android.com/reference/android/app/ActivityManager.html#getLargeMemoryClass() to get the max heap per app, which may be larger than normal heap size.

0

精彩评论

暂无评论...
验证码 换一张
取 消