@@ -0,0 +1,2363 @@
+package jmetest.util;%0A%0Aimport com.jme.scene.Node;%0Aimport com.jme.scene.Spatial;%0Aimport com.jme.scene.TriMesh;%0Aimport com.jme.system.DisplaySystem;%0A%0Apublic class Sizeof %7B%0A   public static void main(String%5B%5D args) throws Exception %7B%0A       // Warm up all classes/methods we will use%0A       runGC();%0A       usedMemory();%0A%0A       // Array to keep strong references to allocated objects%0A       final int count = 100000;%0A       Object%5B%5D objects = new Object%5Bcount%5D;%0A%0A       long heap1 = 0;%0A       DisplaySystem display = DisplaySystem.getDisplaySystem(%22LWJGL%22);%0A       display.createWindow(800, 600, 32, 60, false);%0A       // Allocate count+1 objects, discard the first one%0A       for (int i = -1; i %3C count; ++i) %7B%0A           Object object = null;%0A%0A           // ### Instantiate your data here and assign it to object%0A           object = new Node();%0A           // ###%0A%0A           if (i %3E= 0)%0A               objects%5Bi%5D = object;%0A           else %7B%0A               object = null; // Discard the warm up object%0A               runGC();%0A               heap1 = usedMemory(); // Take a before heap snapshot%0A           %7D%0A       %7D%0A%0A       runGC();%0A       long heap2 = usedMemory(); // Take an after heap snapshot:%0A%0A       final int size = Math.round(((float)(heap2 - heap1)) / count);%0A       System.out.println(%22'before' heap: %22 + heap1 + %22, 'after' heap: %22 + heap2);%0A       System.out.println(%22heap delta: %22 + (heap2 - heap1) + %22, %7B%22 + objects%5B0%5D.getClass()%0A               + %22%7D size = %22 + size + %22 bytes%22);%0A%0A       for (int i = 0; i %3C count; ++i)%0A           objects%5Bi%5D = null;%0A       objects = null;%0A       display.close();%0A       System.exit(0);%0A   %7D%0A%0A   private static void runGC() throws Exception %7B%0A       // It helps to call Runtime.gc()%0A       // using several method calls:%0A       for (int r = 0; r %3C 4; ++r)%0A           _runGC();%0A   %7D%0A%0A   private static void _runGC() throws Exception %7B%0A       long usedMem1 = usedMemory(), usedMem2 = Long.MAX_VALUE;%0A       for (int i = 0; (usedMem1 %3C usedMem2) && (i %3C 500); ++i) %7B%0A           s_runtime.runFinalization();%0A           s_runtime.gc();%0A           Thread.yield();%0A%0A           usedMem2 = usedMem1;%0A           usedMem1 = usedMemory();%0A       %7D%0A   %7D%0A%0A   private static long usedMemory() %7B%0A       return s_runtime.totalMemory() - s_runtime.freeMemory();%0A   %7D%0A%0A   private static final Runtime s_runtime = Runtime.getRuntime();%0A%0A%7D

Test to determne the size of certain objects.