Print

Print


Hi, Matt.

Do you know how to look at memory usage in Java?
 
You'll might want to debug with something like this:
 
----

Runtime runtime = Runtime.getRuntime();

NumberFormat format = NumberFormat.getInstance();

StringBuilder sb = new StringBuilder();
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();

sb.append("free memory: " + format.format(freeMemory / 1024) + "<br/>");
sb.append("allocated memory: " + format.format(allocatedMemory / 1024) + "<br/>");
sb.append("max memory: " + format.format(maxMemory / 1024) + "<br/>");
sb.append("total free memory: " + format.format((freeMemory + (maxMemory - allocatedMemory)) / 1024) + "<br/>");

----

I took the above idea from here.

http://stackoverflow.com/questions/74674/how-to-do-i-check-cpu-and-memory-usage-in-java

You could make that a static method and call it at various points in TestRunEvioToLcio or within one of your drivers in the .lcsim file you're using.

If memory is steadily increasing every event then this indicates some systematic memory leak.  If it looks fine and then explodes on one event,
that indicates some problem with the data of that event.  For instance, there could be a bogus (very large) value that gets into an array size setting
due to corrupted data (e.g. when size of something is read from a data block), which is often what happens to cause these kinds of problems.

--Jeremy

-----Original Message-----
From: Graham, Mathew Thomas 
Sent: Friday, November 09, 2012 12:38 PM
To: Uemura, Sho; Omar Moreno; Per Hansson
Cc: McCormick, Jeremy I.
Subject: OutOfMemory error in jevio?

I'm trying to run over data (from a pretty pristine hps-java build) like this: 
java -Xmx2048m   -cp hps-java/target/hps-java-1.2-SNAPSHOT-bin.jar org.lcsim.hps.evio.TestRunEvioToLcio -x steering/TestRunOfflineRecon.lcsim /nfs/slac/g/hps/mgraham/DarkPhoton/testrun_data/hps_001349.evio.0  -DoutputFile=recon.slcio -d HPS-TestRun-v3


and I get this...

Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Map failed
	at org.lcsim.hps.evio.TestRunEvioToLcio.main(TestRunEvioToLcio.java:188)
Caused by: java.io.IOException: Map failed
	at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:748)
	at org.jlab.coda.jevio.EvioReader.mapFile(EvioReader.java:323)
	at org.jlab.coda.jevio.EvioReader.<init>(EvioReader.java:178)
	at org.lcsim.hps.evio.TestRunEvioToLcio.main(TestRunEvioToLcio.java:186)
Caused by: java.lang.OutOfMemoryError: Map failed
	at sun.nio.ch.FileChannelImpl.map0(Native Method)
	at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:745)
	... 3 more


...

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the HPS-SOFTWARE list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=HPS-SOFTWARE&A=1