Android Question [solved] java.lang.OutOfMemoryError: Java heap space

angel_

Active Member
Licensed User
After an update I get this error

B4X:
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOfRange(Arrays.java:3664)
    at java.lang.String.<init>(String.java:207)
    at com.android.dx.rop.cst.CstString.utf8BytesToString(CstString.java:158)
    at com.android.dx.rop.cst.CstString.<init>(CstString.java:200)
    at com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:420)
    at com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:271)
    at com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:153)
    at com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:127)
    at com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:118)
    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:505)
    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:420)
    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:402)
    at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:253)
    at com.android.dx.command.dexer.Main.parseClass(Main.java:851)
    at com.android.dx.command.dexer.Main.access$7(Main.java:846)
    at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1822)
    at com.android.dx.command.dexer.Main.processClass(Main.java:834)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:802)
    at com.android.dx.command.dexer.Main.access$3(Main.java:773)
    at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1775)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:756)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:650)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:315)
    at com.android.dx.command.dexer.Main.runDx(Main.java:293)
    at com.android.dx.command.dexer.Main.main(Main.java:249)
    at com.android.dx.command.Main.main(Main.java:94)
Picked up _JAVA_OPTIONS: -Xmx1024m -Xms1024m
I have increase the MaxRamForDex but it doesn't work
 

angel_

Active Member
Licensed User
What is MaxRamForDex set to?
MaxRamForDex=2048, appears this error
B4X:
B4A Versión: 8.80
Parseando código.    (0.68s)
Building folders structure.    (0.53s)
Compilando código.    (1.10s)
Compilado códigos de diseños.    (0.05s)
Organizando librerías.    (3.50s)
Generando el fichero R.    (0.97s)
Compilando el código del motor de depuración.    Error

Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
Have you set it while the IDE was closed?
Yes

Did is start after you update Java?
I updated several things of sdkmanager
 

Pendrush

Well-Known Member
Licensed User
With 32bit java MaxRamForDex=2048 is not possible, you must use Java x64 JDK.

EDIT:
I have x64 JDK and MaxRamForDex is set to 4096.
 
Top