1

I'm trying to make a puzzle app. It has a scroll bar with images of all the different puzzles you can choos from. This bitmap takes up a lot of memory and cases the system to crash on my android smart phone, but works fine on my acer tablet.

If i scale down the size of the bitmap, it works fine. Now I'm using two different sizes to use, and uses the screen resultion to determine what size to use. This seems to work on all the devices i tested so far. But I'm afraid that a device with a large resolution may not have a lot of memory and my app will crash.

Is there a way to see how much ram the device has so i can use both resultion and memory to determin what size bitmap to use???

Ted pottel
  • 6,869
  • 21
  • 75
  • 134
  • 1
    I suspect the relevant issue is not the amount of overall memory (visible somewhere in /proc) but rather the heap size of the DVM running your application. – Chris Stratton Jul 06 '13 at 14:37
  • Check here: http://stackoverflow.com/questions/7374246/android-how-get-total-ram-size-of-device – Kostia Jul 06 '13 at 14:41

1 Answers1

1

Is there a way to see how much ram the device has so i can use both resultion and memory to determin what size bitmap to use?

The device RAM does not matter. The available memory for your process matters.

To find out the memory class of your app, call getMemoryClass() on ActivityManager -- that basically returns the amount of available RAM for your process in MB.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • would that provide the memory limit for the process (including native allocations) or the DVM heap limit (excluding native allocations)? – Chris Stratton Jul 06 '13 at 14:57
  • @ChrisStratton: This is the Dalvik VM heap limit (plus, on API Level 10 and below, it also counts bitmaps, even though they are not actually allocated on the DVM heap for those older Android versions). I'm not aware that there's any limit on native allocations, beyond system RAM itself, though I'm not much of an NDK guy, so I may be mis-remembering on that point. – CommonsWare Jul 06 '13 at 15:00