Java.lang.OutOfMemoryError: Java heap space

Earlier today I was working on some packages for Backtrack 5 and I ran into this java error. I was attempting to run a new reporting tool called Magic Tree which is a java application, but every time I opened it, it would crash with the following error.

root@bt:~/Tools# java -jar MagicTree-1487.jar
JarClassLoader: Warning: Null manifest from input stream associated with: lib/MagicTree/XMLWriter.pm
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2786)
        at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
        at com.simontuffs.onejar.JarClassLoader.copy(JarClassLoader.java:1216)
        at com.simontuffs.onejar.JarClassLoader.loadBytes(JarClassLoader.java:580)
        at com.simontuffs.onejar.JarClassLoader.loadByteCode(JarClassLoader.java:542)
        at com.simontuffs.onejar.JarClassLoader.load(JarClassLoader.java:452)
        at com.simontuffs.onejar.JarClassLoader.load(JarClassLoader.java:338)
        at com.simontuffs.onejar.Boot.run(Boot.java:322)
        at com.simontuffs.onejar.Boot.main(Boot.java:166)

At first I was pretty sure that I was missing the perl module XMLWriter but even after installing that I still had the error. Just in case you are installing this on a regular Ubuntu distro you will need:

root@bt:~/Tools# apt-get install libxml-writer-perl

So even after installing this I still had the same error so I dug a little deeper and it seems my Java install was running out of memory. This was kind of odd because the install of Backtrack I am using has 3 gigs of memory. I did some searching and figured out how to pass Java some new memory parameters on the command line.

java -Xms<initial heap size> -Xmx<maximum heap size>

Next I tried some new parameters:

root@bt:~/Tools# java -Xms128m -Xmx512m -jar MagicTree-1487.jar

Increasing the memory in this way allowed magic tree to open and function properly. It does seem I am having some Jave memory leak issues but for now this is a quick and dirty fix to the problem.


List Price: $121.60 USD
New From: $84.54 USD In Stock
Used from: $7.72 USD In Stock


List Price: $39.99 USD
New From: $9.97 USD In Stock
Used from: $0.01 USD In Stock

Share