Update of /cvsroot/nice/Nice/src/nice/tools/testsuite
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11944/src/nice/tools/testsuite
Modified Files:
TestNice.java
Log Message:
Allow to wait at the end of a testsuite run, to inspect memory usage
with a memory debugger.
Index: TestNice.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/nice/tools/testsuite/TestNice.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** TestNice.java 28 Nov 2003 02:57:13 -0000 1.28
--- TestNice.java 26 Jan 2004 12:42:44 -0000 1.29
***************
*** 149,152 ****
--- 149,159 ----
/**
+ Whether to wait at the end of the run.
+ This is useful for profiling memory after all the work is done,
+ using a debugger/memory profiler.
+ */
+ private static boolean _wait;
+
+ /**
* Classpath entry that contains the Nice standard library.
*
***************
*** 195,198 ****
--- 202,217 ----
e.printStackTrace();
}
+
+ if (_wait)
+ {
+ reclaimMemory(true);
+
+ System.out.println("Test finished.\nPress return to terminate:");
+ try {
+ new DataInputStream(System.in).readLine();
+ }
+ catch (IOException e) {}
+ }
+
_output.endApplication();
***************
*** 200,204 ****
_output.close();
-
if (getTestCasesFailed() > 0)
System.exit(1);
--- 219,222 ----
***************
*** 210,214 ****
--- 228,253 ----
}
+ private static void reclaimMemory(boolean clear)
+ {
+ // Reclaim memory.
+ bossa.modules.Package.startNewCompilation();
+ mlsub.typing.NullnessKind.setSure(null);
+ mlsub.typing.NullnessKind.setMaybe(null);
+
+ // Create an OutOfMemoryError, so that soft references are also let loose.
+ if (clear)
+ try {
+ int[] l = new int[1000];
+ for (;;)
+ {
+ l = new int[l.length * 2];
+ }
+ }
+ catch (OutOfMemoryError e) {}
+
+ System.gc();
+ nice.tools.compiler.console.fun.printMemoryUsage();
+ }
/**
***************
*** 228,231 ****
--- 267,272 ----
else if ("-runtime".equalsIgnoreCase(s))
_runtime = args[i++];
+ else if ("-wait".equalsIgnoreCase(s))
+ _wait = true;
else
return false;
***************
*** 555,557 ****
--- 596,599 ----
// Local Variables:
// tab-width: 2
+ // indent-tabs-mode: t
// End:
|