Performance Zone is brought to you in partnership with:

Computer Science Engineer having more than 14 years of experience, predominantly in the Enterprise Product Development Space. Professionally started with LabWindows, then to X-Windows/Motif and landed in using Java. Primitive experience in VC++ and .Net. Making hands dirty with DSLs in the free time (?) For more about me, visit http://jagannathan.info Jagannathan is a DZone MVB and is not an employee of DZone and has posted 5 posts at DZone. You can read more from them at their website. View Full User Profile

Visual GC

01.19.2013
| 6432 views |
  • submit to reddit

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 I wrote a small code to test the VisualGC output from JVisualVM and following are a 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. :)

Published at DZone with permission of Jagannathan Asokan, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)