1 19 20 package org.apache.excalibur.instrument.manager.http; 21 22 import java.io.IOException ; 23 import java.io.PrintWriter ; 24 import java.util.Map ; 25 26 import org.apache.excalibur.instrument.manager.DefaultInstrumentManager; 27 import org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor; 28 import org.apache.excalibur.instrument.manager.NoSuchInstrumentSampleException; 29 30 36 public class XMLGCHandler 37 extends AbstractXMLHandler 38 { 39 42 48 public XMLGCHandler( DefaultInstrumentManager manager, 49 InstrumentManagerHTTPConnector connector ) 50 { 51 super( "/gc.xml", manager, connector ); 52 } 53 54 57 64 public void doGet( String path, Map parameters, PrintWriter out ) 65 throws IOException 66 { 67 long oldMemory = getMemory(); 68 69 System.gc(); 70 71 long newMemory = getMemory(); 72 73 out.println( InstrumentManagerHTTPConnector.XML_BANNER ); 74 out.println( "<gc old-memory=\"" + oldMemory + "\" new-memory=\"" + newMemory + "\"/>" ); 75 } 76 77 80 private long getMemory() 81 { 82 Runtime rt = Runtime.getRuntime(); 83 return rt.totalMemory() - rt.freeMemory(); 84 } 85 } 86 87 | Popular Tags |