Piotr Gabryanczyk’s Blog

Java, Refactoring, AOP, Spring, DDD, TDD, etc.

  • Blogroll

    • I have joined Anti-IF Campaign

Archive for the ‘jvm’ Category

IntelliJ idea.exe.vmoptions revised for version 7 and JDK 6

Posted by Piotr Gabryanczyk on June 26, 2007

IntelliJ 7 was a bit unstable with JDK 1.6 on previous set of options I presented on this blog so I decided to tweak it again.

Here are the options I ended up with:

-Xms256m
-Xmx256m
-XX:MaxPermSize=150m
-XX:MaxGCPauseMillis=10
–XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
–XX:+CMSIncrementalPacing
-Didea.no.jdk.check=true

Advertisements

Posted in intellij, java, jvm | 2 Comments »

Closures in Java – catching up with Smalltalk?

Posted by Piotr Gabryanczyk on March 31, 2007

I was recently very happy to discover that there is proposal for closures in java. I have been waiting for this to happen since I haven’t even started programming in java in 1998, when I learned Smalltalk and wrote quite a useful system within two weeks in it.

I like most of the ideas in the proposal – good job gentelman! (no ladies participated yet…)

One thing which I find annoying is the declaration of types for the parameters of the closure, i.e.

runWithinTransaction(){
Transaction txn, Session s =>
...
}

It seams to me that if runWithinTransaction() accepts {Transaction txn, Session s => boolean} closure type, it is kind of redundant to repeat the types of parameters in the closure itself. So I would appreciate a bit of syntactic sugar here (or actually lack of it) and do it as follows:

runWithinTransaction(){
txn, s =>
...
}

Or even like other languages (Smalltalk, Ruby):

runWithinTransaction(){ |txn, s| ... }

I know I might sound like an ignorant here. The compiler writers will have more difficult job with guessing types of the parameters.
Purists might also start crying about lack of explicity here, as you can’t see the parameters type at the first sight… Come on it is no worse than casts when using collections in java under 1.5.

I wish we will see closures in java soon!

Posted in java, jvm | Leave a Comment »

IntelliJ and Garbage Collection

Posted by Piotr Gabryanczyk on December 12, 2006

I recently read the article about garbage collection (here) and decided to tweak my IntelliJ settings.

I am using IntelliJ 6.0.2 and JDK 1.5.0_08.

I ended up with the following settings:

-Xms256m
-Xmx512m
-XX:MaxPermSize=200m
-XX:MaxGCPauseMillis=10
–XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
–XX:+CMSIncrementalPacing

Let’s explain them:

Heap size

-Xms256m
-Xmx512m

The more the better…

Perm size

IntelliJ likes a lot of memory for caching references and class meta information. That is why we need to make sure that cache is not purged. Cache is stored in “Old Generation” space which size is determined by the following option

-XX:MaxPermSize=200m

200m is good for the size of project I am using. General rule is to observe memory indicator after using find symbol option with include non project files selected. If it doesn’t move you have chosen enough memory.

Maximum Pause

-XX:MaxGCPauseMillis=10

We ask GC to pause the application for no more then 10 milliseconds.

Proportion of free space

-XX:MaxHeapFreeRatio=70

We ask GC to kick off when more than 30% of memory is occupied, so when we start compilation GC will not interfere because it will be enough memory free.

Concurrent Mark-Sweep (CMS) Collector

-XX:+UseConcMarkSweepGC

We want GC to run in parallel with other threads without freezing the application. This option doesn’t stop GC from freezing the application but it reduces it significantly.

Incremental Mode

–XX:+CMSIncrementalPacing

We don’t wont to freeze the application so we do GC incrementally with breaks so the application can take a breath. We use Pacing so GC can learn how to use CPU based on application CPU usage.

Posted in intellij, java, jvm | 21 Comments »