David Martinelli
David Martinelli

Reputation: 233

How can I retrieve the max heap available on device?

I have a problem. My app use 20MB of ram so I want to avoid mobile phone that have heap less than 20MB. I tried with Runtime.getRuntime.maxMemory() but this function retrieve me the wrong result (256MB on SGS3) because I want to retrieve the available heap for a single app.

How can I detect it? There is an attribute in the manifest?

Thanks.

Upvotes: 1

Views: 102

Answers (1)

Blackbelt
Blackbelt

Reputation: 157447

What you need is getMemoryClass

 ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();

it returns the approximate per-application memory class of the current device.

Upvotes: 1

Related Questions