EdmondFrank's 时光足迹

この先は暗い夜道だけかもしれない それでも信じて進むんだ。星がその道を少しでも照らしてくれるのを。
或许前路永夜,即便如此我也要前进,因为星光即使微弱也会我为照亮前途。
——《四月は君の嘘》

错误:Could Not Reserve Enough Space for Object Heap的解决方案

错误:Could not reserve enough space for object heap的解决方案

Reason:

If you go thru this IBM link on java, it says that on 32 bit windows the recommended heap size is 1.5 GB and the Maximum heap size is 1.8 GB. So your jvm does not gets initialized for -Xmx2G and above.

Also if you go thru this SO answer, clearly the DLL bindings are an issue for memory reservation changing which is no trivial task. Hence what may be recommended is that you go for 64-bit Windows and a 64-bit JVM. while it will chew up more RAM, you will have much more contiguous virtual address space.

Method to fix:

For Windows

Go to Start → Control Panel → System → Advanced system settings → advanced(tab) → Environment Variables → System Variables → New:

Variable name: _JAVA_OPTIONS Variable value: -Xmx512M

For Linux

1
export _JAVA_OPTIONS=-Xmx512M

or

1
export _JAVA_OPTIONS=-Xmx1024M 

For Android Studio

Project > Gradle Scripts > gradle.properties

org.gradle.jvmargs=-Xms512m -Xmx1024m