Michael
Michael

Reputation: 9402

How to allocate more than 25MB in an android app, api level 8?

I'm trying to write a quick android app to exert memory pressure on another app that I am debugging, and I am running into a big problem, namely that I cannot allocate more than 25MB, even if I allocate in as small as 4k chunks.

I found that there is a manifest attribute I can add to the application tag, android:largeHeap="true" but it apparently wasn't added until API level 11, and I need to target API level 8.

Yet I know this is possible somehow because Firefox regularly takes 60-80MB of RAM, which is 2-3x what my test app is able to take.

Upvotes: 0

Views: 630

Answers (1)

Raghav Sood
Raghav Sood

Reputation: 82533

The only way to allocate more than the heap limit on a device is to allocate outside the heap. That is to say, you'll need to use the NDK to allocate more memory to your app, which is what Firefox does.

Apart from that, you cannot allocate more. In 99% of the cases, you don't need to allocate more. You just need to use more efficiently what you have.

Upvotes: 2

Related Questions