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

Discussion in 'Android Questions' started by angel_, Mar 17, 2019.

  1. angel_

    angel_ Member Licensed User

    After an update I get this error

    Code:
    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    What is MaxRamForDex set to? Have you set it while the IDE was closed?

    Did is start after you update Java?
    This line suggests that there is an environment variable that affects compilation.
     
  3. angel_

    angel_ Member Licensed User

    MaxRamForDex=2048, appears this error
    Code:
    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
    Yes

    I updated several things of sdkmanager
     
  4. OliverA

    OliverA Well-Known Member Licensed User

  5. Erel

    Erel Administrator Staff Member Licensed User

    Seems like there isn't enough memory available on your PC. How much RAM is installed? Try to close other apps.
     
  6. angel_

    angel_ Member Licensed User

  7. DonManfred

    DonManfred Expert Licensed User

    are you using 32bit of Java?
     
    Erel likes this.
  8. angel_

    angel_ Member Licensed User

    I think so.

    With B4I I have no problems
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    I think that your computer ran out of available memory. You should actually decrease MaxRamForDex.
     
  10. Pendrush

    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.
     
    angel_ and Erel like this.
  11. Erel

    Erel Administrator Staff Member Licensed User

    You are correct. This is the cause of this issue here.
     
  12. angel_

    angel_ Member Licensed User

    I have set MaxRamForDex to 4096 and JDK x64, it works perfectly

    Thank you
     
    DonManfred likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice