|
Message
From: cvs at opencores.org<cvs@o...>
Date: Wed Jan 30 14:07:35 CET 2008
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/08/01 30:14:07 Modified: jop/java/target/src/test/gctest GCTest1.java Log: changed to single thread test Revision Changes Path 1.3 jop/java/target/src/test/gctest/GCTest1.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gctest/GCTest1.java.diff?r1=1.2&r2=1.3 (In the diff below, changes in quantity of whitespace are not shown.) Index: GCTest1.java =================================================================== RCS file: /cvsroot/martin/jop/java/target/src/test/gctest/GCTest1.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- GCTest1.java 30 Oct 2006 00:43:37 -0000 1.2 +++ GCTest1.java 30 Jan 2008 13:07:35 -0000 1.3 @@ -1,28 +1,29 @@ package gctest; -import joprt.RtThread; - -import com.jopdesign.sys.Const; -import com.jopdesign.sys.GC; -import com.jopdesign.sys.Native; - -// GCTest1 -// Tests if GC collects the garbage object. The GC is explicitly invoked. +/** + * Tests if GC collects the garbage object. The GC is explicitly invoked. + */ public class GCTest1 { + static Runtime rt = Runtime.getRuntime(); + public static void main(String s[]) { - new RtThread(20, 1000000) { - public void run() { + + System.out.print("Total memory: "); + System.out.println((int) rt.totalMemory()); + System.out.print("Free memory: "); + System.out.println((int) rt.freeMemory()); + String allocStr = "Allocation problem!"; String refStr = "Reference problem"; Garbage garbage = new Garbage(); int prevId = garbage.id; - GC.gc(); - int freeHeap = GC.freeMemory(); - for (;;) { - if (freeHeap != GC.freeMemory()) { + System.gc(); + int freeHeap = (int) rt.freeMemory(); + for (int i=0; i<10; ++i) { + if (freeHeap != (int) rt.freeMemory()) { System.out.println(allocStr); } garbage = new Garbage(); @@ -33,18 +34,10 @@ } prevId = garbage.id; - GC.gc(); //Remove the old garbage object + System.gc(); //Remove the old garbage object - waitForNextPeriod(); - } } - }; - RtThread.startMission(); - - for (int i = 0; i < 10; ++i) { - RtThread.sleepMs(1000); - } System.out.println("Test 1 OK"); } }
|
 |