B4J Question Out of memory error: Java Heap Space, in jar after compile

Discussion in 'B4J Questions' started by TorontoJim, Apr 10, 2016.

  1. TorontoJim

    TorontoJim Member Licensed User

    I'm trying to read from a KVS file and populate a table view. I get the following error in the released jar, but not in the IDE launced jar (debug or release mode) OR in a windows executable of the jar.

    I think this means that an object stored in the KVS file is too big (an image, probably) ... but that's just a guess. But if so, why would it crash the released jar but not the IDE launched jar or the windows exe?

    I have no background in java so I have no idea what Java heap space is, or why it would cause the app to be out of memory. Sorry. Noob here.

    keyvaluestore._getobjectinternal (java line: 202)
    java.lang.OutOfMemoryError: Java heap space
        at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readHelper(
        at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadObject(
        at b4j.example.keyvaluestore._getobjectinternal(keyvaluestore.java:
        at b4j.example.keyvaluestore._getobject(keyvaluestore.java:
        at b4j.example.main._loadkvsdata(main.java:
        at b4j.example.main._combofilefield_selectedindexchanged(main.java:
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
        at anywheresoftware.b4a.BA$
        at com.sun.javafx.application.PlatformImpl.lambda$
    null$173(Unknown Source)
        at com.sun.javafx.application.PlatformImpl$$Lambda$
    50/7912477.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$
    174(Unknown Source)
        at com.sun.javafx.application.PlatformImpl$$Lambda$
    49/9599617.run(Unknown Source)
        at com.sun.glass.ui.InvokeLaterDispatcher$
    Future.run(Unknown Source)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$
    null$148(Unknown Source)
        at com.sun.glass.ui.win.WinApplication$$Lambda$
    38/20085625.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
  2. Erel

    Erel Administrator Staff Member Licensed User

    This error means that the process ran out of available memory.

    Have you changed the #VirtualMachineArgs attribute? It will only affect the app while it runs from the IDE.

    If you are running it from the command line then you can request a larger heap size:
    java -Xmx2048m -jar <your jar>
    Mashiane likes this.
  3. TorontoJim

    TorontoJim Member Licensed User

    No, I didn't change that attribute. I'll work at nailing down where the memory is getting eaten up.
  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