2

I want to increase the default virtual memory heap size of my avd. I am using Eclipse 3.7.2 for development and when I create (or edit) a avd I set the "Max VM application heap" to 64MB. If I select Details it confirms this and if I inspect the config.ini file i see that "vm.heapSize=64" which is correct. The problem is that this is not actually true when running the avd.

In my application I run "Runtime.getRuntime().maxMemory();" which shows 24MB!!!!

Likewise,

ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
int memoryClass = am.getMemoryClass();

Shows 24MB

UPDATE: I noticed that in hardware-qemu.ini the "vm.heapSize=24" ? I changed the value to 64, but when I launch the avd it gets changed back to 24?

UPDATE: totalMemory() returns ~15MB

UPDATE: ADT version is 20.0.1

UPDATE: I have tested this a bunch, making many different AVDs with many different settings and all I can conclude is that the AVD or Eclipse is a bit buggy and often does not reflect the settings values you enter for the AVD. Note that I have made AVD devices that do reflect vm.heapSize=64.

esse
  • 5,183
  • 3
  • 14
  • 20

2 Answers2

1

Based on this Google Groups question and my interpretation of the documentation sounds like those values would be fore your application only and not the entire emulator.

I would be curious to see if totalMemory() would return 64m. Here is the documentation.

Edit: getMemoryClass() according to the documentation:

Return the approximate per-application memory class of the current device.

Which boils down to there is no programmatic way that I can find to get the heap size of the emulator (device).

Edit 2: I think you may be able to find your answer here as well. - Android How do you get total memory RAM in the device?

Good luck.

Community
  • 1
  • 1
bytebender
  • 7,088
  • 2
  • 28
  • 54
  • This question has not been answered, I still don't know why the settings are not actually updating the avd, why the hardware-qemu.ini file gets overwritten. I did go back to old questions that were answered and accepted, thanks for the heads up. – esse Jul 24 '12 at 00:07
  • It's not being overwritten you are setting the heap size for the entire emulator and then asking it for the heap size of an individual app. – bytebender Jul 24 '12 at 03:14
  • I don't think that is correct, the setting states "Max VM application heap," not emulator. In addition, some default configs set the heap at 48, and that is reflected in both config files. Furthermore, the emulator VM is probably gte 64 and definitely gte 24 which is the default VM size for some predefined configs. – esse Jul 24 '12 at 05:59
  • It is correct see this question as well - http://stackoverflow.com/questions/2630158/detect-application-heap-size-in-android/9428660#9428660 see edits above as well. – bytebender Jul 24 '12 at 15:09
  • Your response is correct, but it does not answer my question, though it has informed me. Provided links are very informative and I have read the documentation again more closely, and this discussion has helped clarify my question to me. “maxMemory()” does refer to the Dalvik VM and the max memory that can be used before a hard error. “getMemoryClass() gives me the amount of memory my app should try to stay below to be nice. My question boils down to the two following points: 1) how do we increase the size of the VM memory. 2) Why the “Max VM application heap” value is not updated in the VM? – esse Jul 24 '12 at 16:49
  • The very last link in my response tells you how to check the total memory for the device (You have to get it via linux not android). You increase the VM size via the config setting in the AVD as you have already done. Good luck! – bytebender Jul 24 '12 at 16:59
0

It seem like hardware.ini has priority over config.ini from your skins folder (something like platforms\android-8\skins\WVGA800 depending on your default resolution selected)

CesarC
  • 78
  • 5
  • It has been a little while, but I believe I had modified each of those files and it would not actually change the size. – esse Sep 26 '12 at 03:49