How to Manually Set Android VM Heap Size in Emulator?

Viewed 703

How do you manually set the VM heap size for Android Studio emulators?

I'm trying to set it really low to make sure my app will still run without out-of-memory errors even on really old devices.

I did this in the emulator settings:

enter image description here

And added this code to check:

Runtime rt = Runtime.getRuntime();
        long maxMemory = rt.maxMemory();
        Log.v("onCreate", "maxMemory:" + Long.toString(maxMemory));
        ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        int memoryClass = am.getMemoryClass();
        Log.v("onCreate", "memoryClass:" + Integer.toString(memoryClass));

... but I still get this:

enter image description here

Since I changed the settings, why does it not reflect that by saying "maxMem: 128 memoryClass: 16??"

0 Answers
Related