gcj: mem leaks & speed.

Andrew Haley aph@redhat.com
Mon Feb 2 11:26:00 GMT 2004


For a memory allocation performance comparison, try something
(slightly) more realistic, like this:

public class Leak {
  static Leak head;
  Leak prev;
  Leak ()
  {
	prev = head;
	head = this;
  }
	
  static final int iters = 1000000;

  public static void main(String[] argv) {
	long start = System.currentTimeMillis();
	for (int i = 0;; i++) {
	  Leak l = new Leak();
	  if (i % iters == 0) {
		long curr = System.currentTimeMillis();
		System.out.println(i / iters + ": " + (curr - start));
		head = null;
	  }
	}
  }
}



More information about the Java mailing list