Tuesday, January 21, 2014

Garbage Collection: testing the GC plugin for VisualVM

Watch the excellent tutorial

Install VisualVm GC plugin (I had to download it locally to install it, I could not install directly...) (beware, you should use visualvm for java 7, otherwise the plugin installation will fail)

I run this test code:

package com.pierre.gctests;

import java.util.ArrayList;

public class PVOOM {
 public static void main(String[] args) throws InterruptedException {
  ArrayList al = new ArrayList(); 
  for (int i = 0; i < 1000000; i++) {
   for (int j = 0; j< 1000; j++) {  
    al.add(new Animal(Integer.toString(i)));
   }
   Thread.sleep(1);
   
  }
 }
}

class Animal {
 public Animal(String name) {
  super();
  this.name = name;
 }

 String name;
 
}



I run it with Java 7 and I get this:



No comments: