//parser.setErrorHandler(new StreamErrorHandler());
// We use parse(URL, URL) here instead of parseFile(String)
// because parseFile() works best on relative pathnames and
// has problems finding resources like files specified in
// parameters if the xml file was specified as an absolute path.
CompositeActor toplevel = null;
// First, we gc and then print the memory stats
// BTW to get more info about gc,
// use java -verbose:gc -Xloggc:filename . . .
System.gc();
Thread.sleep(1000);
Runtime runtime = Runtime.getRuntime();
try {
URL url = new URL(null, xmlFilename);
toplevel = (CompositeActor) parser.parse(url, url.openStream());
} catch (Exception ex) {
File f = new File(xmlFilename);
URL url = f.toURI().toURL();
System.err.println("Warning: Parsing '" + xmlFilename
+ "' failed: ");
ex.printStackTrace();
System.err.println(" Trying '" + url + "'");
toplevel = (CompositeActor) parser.parse(null, url);
}
// FIXME: nearly duplicate code in kernel/KernelMain.java
SDFDirector director = (SDFDirector) toplevel.getDirector();
if (director != null) {
Parameter iterations = (Parameter) director
.getAttribute("iterations");
Parameter copernicus_iterations = (Parameter) director
.getAttribute("copernicus_iterations");
// Set to be a large number of iterations, unless
// copernicus_iterations is set.
if (copernicus_iterations != null) {
iterations.setToken(copernicus_iterations.getToken());
} else {
iterations.setToken(new IntToken(100000));
}
System.out.println("TestApplication: Setting Iterations to "
+ iterations.getToken());
}
Manager manager = new Manager(toplevel.workspace(), "TestApplication");
toplevel.setManager(manager);
toplevel.addChangeListener(this);
String modelName = toplevel.getName();
long startTime = System.currentTimeMillis();
long totalMemory1 = runtime.totalMemory() / 1024;
long freeMemory1 = runtime.freeMemory() / 1024;
System.out.println("Spent " + (startTime - _parseStartTime)