Recommended JVM flags for Clojure

892 views
Skip to first unread message

Gabi

unread,
Jan 7, 2010, 4:20:30 AM1/7/10
to Clojure
Hello fellow Clojurians,

I got lots of "java.lang.OutOfMemoryError: GC overhead limit exceeded
" exceptions ,and after a short investigation added the following
flags (JVM 1.6.0_17):
-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:
+CMSIncrementalPacing

These flags seems to solve the problem, but I am interested in your
experience and best practices regarding JVM flags in clojure.

I know it really depends on the type of the application, but it seems
to me that the gc is working really hard under Clojure (I cannot prove
it, this is just an impression)

Gabi

kyle smith

unread,
Jan 7, 2010, 11:47:37 AM1/7/10
to Clojure
First, make sure you have -server. If you can spare more heap, use -
Xmx1g . If you're on a 64bit jvm, -XX:+UseCompressedOops adds a
significant boost. A flag that helps quite a bit is -XX:
+DoEscapeAnalysis . Finally, if you want to play around with the JIT
threshold, use -XX:CompileThreshold=n , where n defaults to 10000.

Stuart Sierra

unread,
Jan 7, 2010, 1:57:28 PM1/7/10
to Clojure
I use -XX:+UseConcMarkSweepGC. And don't forget -Xmx, just having a
bigger heap can solve some problems. Some people have found it
necessary to increase the PermGen size, but usually only for programs
that generate a lot of functions dynamically.

-SS

Gabi

unread,
Jan 7, 2010, 3:57:32 PM1/7/10
to Clojure
Thanks I'll try those flags. I indeed use 64 bits

Albert Cardona

unread,
Jan 7, 2010, 4:47:30 PM1/7/10
to clo...@googlegroups.com
What I use:

-Xincgc : enable incremental garbage collector. Works great when
there's more than 1 CPU

-Xms4000m -Xmx4000m : set both min and max heap size to the same
amount (4 Gb in this case). Prevents dynamic heap resizing, which at
high loads may result in unexpected out of memory errors and long
pauses.

Albert
--
http://albert.rierol.net

Seth

unread,
Jan 7, 2010, 9:40:13 PM1/7/10
to Clojure
Hi Gabi,

This may not be useful, but have you tried running the Clojure new
branch? Rich implemented fine-grained locals clearing on the new
branch, and it helps avoid holding onto unused data accidentally.

http://groups.google.com/group/clojure/browse_thread/thread/14baed8f26097515/583cd8375a0d446d

Seth

borgees

unread,
Jan 7, 2010, 11:26:59 AM1/7/10
to Clojure
Have you tried running with escape analysis on? It might help take
some of the burden off the garbage collector.

-XX:+DoEscapeAnalysis

On Jan 7, 4:20 am, Gabi <bugspy...@gmail.com> wrote:

Gabi

unread,
Jan 8, 2010, 5:01:03 AM1/8/10
to Clojure
Ok guys,

After trying all your suggestions, here is the combination that worked
best for me (in the order of their impact solving the problem):

JVM_FLAGS="-server \
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode \
-XX:+UseCompressedOops \
-XX:+DoEscapeAnalysis \
-XX:+UseBiasedLocking \
-XX:PermSize=64M \
-XX:MaxPermSize=256M \
-Xmx2g"


Now my app consumes ~500M of resident memory, but at least does not
crash and performance does not deteriorate.

BTW, I also tried the 'new' branch suggested . Didn't see any
noticeable effect.

On Jan 8, 4:40 am, Seth <seth.schroe...@gmail.com> wrote:
> Hi Gabi,
>
> This may not be useful, but have you tried running the Clojure new
> branch? Rich implemented fine-grained locals clearing on the new
> branch, and it helps avoid holding onto unused data accidentally.
>

> http://groups.google.com/group/clojure/browse_thread/thread/14baed8f2...
>
> Seth

Reply all
Reply to author
Forward
0 new messages