Craig Neil Brown
Craig Neil Brown

Reputation: 61

How to Get the VM Budget in Android for Bitmaps?

Is there some way to find the VM budget for bitmaps?

My app displays two photographs at once and this is possible given appropriate scaling and colour depth, but, if the device has a bigger VM budget (as some do), I would like the app to use it for better image quality. Is there an API call to get the VM budget?

I have done this using binary trial and error but it is slow.

Any help would be very much appreciated.

Upvotes: 0

Views: 170

Answers (2)

yushulx
yushulx

Reputation: 12160

I think you can try Runtime class.

Runtime rt = getRuntime();
rt.totalMemory(); //Returns the total amount of memory which is available to the running program.

refer to http://developer.android.com/reference/java/lang/Runtime.html

Upvotes: 1

Kai
Kai

Reputation: 15476

You can use ActivityManager.getMemoryClass() to get the amount of memory allowed per process, then deduct the estimated maximum amount of memory your code needs, the rest can be used for displaying your images.

Upvotes: 1

Related Questions