// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class DynMem {
    private static final int REP = 1000;
    public static void main(String[] args) {
        for(int siz = 100; siz <= 100000; siz *= 10) {
            int n = 10000000 / siz;
            long t1 = System.currentTimeMillis();
            for(int i = 0; i < REP; i++) {
                byte[][] a = new byte[n][];
                for(int j = 0; j < n; j++) {
                    a[j] = new byte[siz];
                }
                // a is ready for GC
            }
            long t2 = System.currentTimeMillis();
            System.out.println("size=" + siz + " n=" + n + ": " + (t2-t1)/1000.0 + " seconds");
        }
    }
}
