Skip to content

Visual GC

December 22, 2011

Most of us are aware of the Java Tuning using the heap sizing, GC settings. But there are several more which one can use. Please refer the following websites for more details.

http://java.sun.com/performance/reference/whitepapers/tuning.html

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html#largepages

I was curious to know, how the Permgen, Oldgen, Eden spaces look (I can think of Hell or Heaven as no one has experienced :) )

So wrote a small code to test the VisualGC output from JVisualVM and following are few results which you can see. The details need to written as it would consume some more time for me to understand / digest.

public class StudentBean {

private long sId;
private String fName;
private String sName;

private String division;
private String address;

public StudentBean(long sId, String fName, String sName, String division,
String address) {
super();
this.sId = sId;
this.fName = fName;
this.sName = sName;
this.division = division;
this.address = address;
}

@Override
public String toString() {
return “StudentBean [sId=" + sId + ", fName=" + fName + ", sName="
+ sName + ", division=" + division + ", address=" + address
+ "]“;
}

public long getsId() {
return sId;
}
public void setsId(long sId) {
this.sId = sId;
}
public String getfName() {
return fName;
}
public void setfName(String fName) {
this.fName = fName;
}
public String getsName() {
return sName;
}
public void setsName(String sName) {
this.sName = sName;
}
public String getDivision() {
return division;
}
public void setDivision(String division) {
this.division = division;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}

}

import java.util.Random;

public class StudentTest {

public static void main(String[] args) throws InterruptedException {

Random randomize = new Random();
for(;;) {

StudentBean sBean = new StudentBean(randomize.nextLong(), Integer.toString(randomize.nextInt()), Integer.toString(randomize.nextInt()), Integer.toString(randomize.nextInt()), Integer.toString(randomize.nextInt()));
System.out.println(sBean);
Thread t = Thread.currentThread();
synchronized (t) {
t.wait(3000);
}
}
}

}

Default

-Xms128M -Xmx256M

-Xms128M -Xmx256M -Xmn64M

-Xms128M -Xmx256M -Xmn64M -XX:+UseConcMarkSweepGC

-Xms128M -Xmx256M -Xmn64M -XX:+UseParallelGC

-Xms128M -Xmx256M -Xmn64M -XX:+UseSerialGC

I would like to experiment the other options as well. The number of permutations and combinations would be high, but wanted to have a fair idea of how the Java Memory Model changes based on the Java options which are given by the user while invoking the JRE.

Will write a more detailed report(?) based on my understanding / grasping power. :)

About these ads
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: