@Before public void setUp() throws Exception { disableOutput(); model = new Earth(); System.gc(); runtime.gc(); }
@After public void tearDown() throws Exception { enableOutput(); dbFile = new File(Constants.DATABASE_FILE); if (dbFile.exists()) System.out.println("#DBFILESIZE:" + dbFile.length()); model = null; System.gc(); runtime.gc(); }
@BeforeClass public static void initialize() throws InterruptedException { Runtime rt = Runtime.getRuntime(); rt.gc(); freeMemory_preUse = rt.freeMemory(); ResourceManager rm = new ResourceManager(); for (int i = 0; i < 1000; i++) { Object key = Integer.toString(i); keyList.add(key); resourceList.add(rm.getResource(key)); } rt.gc(); freeMemory_useRes = rt.freeMemory(); for (int i = 0; i < 1000; i++) { Object key = keyList.get(i); Resource res = resourceList.get(i); res.use(key); } for (int i = 0; i < 1000; i++) { Resource res = resourceList.get(i); res.release(); } keyList.clear(); // リソースへの参照をすべて削除 resourceList.clear(); // リソースへの参照をすべて削除 rm.shutdown(); rt.gc(); rm.reaper.join(); rt.gc(); freeMemory_clearRes = rt.freeMemory(); System.out.println("freeMemory_preUse :" + freeMemory_preUse); System.out.println("freeMemory_useRes :" + freeMemory_useRes); System.out.println("freeMemory_clearRes:" + freeMemory_clearRes); }