Clojure STM Out of Memory

Go To StackoverFlow.com

3

I have a small program that should perform parallel banking transfer using the STM, so I am testing it on different machines, 2-core and a 1-core. In the 2-core machines everything works, but in the 1-core machine, the Java Out of Memory error is thrown when I perform 1 million parallel transactions.

The error is the following "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

Also I have a Java-synchronize version of the same program which works, even if it is slower, it can reach a million transactions.

What can I do to make my Clojure application work in the 1-core machine? I am afraid the garbage collector can't handle so many Refs...what do you think?

Thanks a lot for your help!

Update: It works now, I did java -Xmx1000m -jar myprog.jar and worked perfectly!

I didn't know it was possible to increasing the heap size for the JVM, and that was exactly my problem. Thanks a lot to "sw1nn" for the great comment ;)

2012-04-04 19:30
by nuvio
Have you tried increasing the heap size for the JVM with the -Xmx options? For 32-bit JDK you are limited to around 1500M, but can go much higher with 64-bit. If you increase the limit and the program fails (but later on), you likely have a memory leak. But it's possible you just need a bit more heap on the 1-core machine - sw1nn 2012-04-04 21:11
Oh great! How can I actually do that, from command line? Do you have any link? Thanks a lot - nuvio 2012-04-04 21:17
java -Xmx1500m -cp clojure-1.3.0.jar clojure.main -i myclojure.cl - sw1nn 2012-04-04 22:11
Amazing! it work now, I did java -Xmx1000m -jar myprog.jar and worked perfectly! Thank you!! P.S. you could write it as answer.. - nuvio 2012-04-04 23:35
Great, glad to be of help - sw1nn 2012-04-05 05:48


2

You can also add jvm-opts to your leiningen project.clj like below:

:jvm-opts ["-Xmx1500m"]

to get it specified when you run your program in leiningen.(like testing)

2013-03-13 00:27
by ktsujister
Ads