diff --git a/README.md b/README.md index 10f2937..9b5989d 100644 --- a/README.md +++ b/README.md @@ -91,9 +91,28 @@ remote applications: ## Output - export format +There are summary metrics to measure: + +``` +ActionName,ExecutionIteration,Timestamp,UsedMemory,CPUTime +monitor-1,0,2019.06.03.17.20.21,19800024,46190000000 +monitor-1,1,2019.06.03.17.20.25,19856992,46900000000 +monitor-2,0,2019.06.03.17.20.26,19917168,46900000000 +monitor-2,1,2019.06.03.17.20.28,19977176,46900000000 +``` +There are two outputs, Heap: + +``` +ActionName,ExecutionIteration,NameOfObject,ByteOrderBySize,Size,Count +monitor-1,0,java.lang.String (retained),58918,58918 +monitor-1,0,int[],29849,29849 +monitor-1,0,char[],60273,60273 +``` + + ## Recommended tools @@ -120,6 +139,8 @@ remote applications: Build >= JDK12 + For package: mvn package. + ## Support It is an open source project and no enterprise support is provided, only by the community. diff --git a/conf/rmjvm-dicoogle.yml b/conf/rmjvm-dicoogle.yml index dd9ce23..f8cecda 100644 --- a/conf/rmjvm-dicoogle.yml +++ b/conf/rmjvm-dicoogle.yml @@ -15,12 +15,12 @@ actions: cmd: "c:\\Users\\bastiao\\Software\\dcm4che-5.16.3-bin\\dcm4che-5.16.3\\bin\\ianscu.bat -c DICOOGLE-STORAGE@localhost:6666" timeout: 0 # ms monitor: ['cpu', 'mem'] - executions: 10 + executions: 2 - name: monitor-dicom-qr cmd: "c:\\Users\\bastiao\\Software\\dcm4che-5.16.3-bin\\dcm4che-5.16.3\\bin\\ianscu.bat -c DICOOGLE-STORAGE@localhost:1045" monitor: ['mem'] timeout: 0 # ms - executions: 100 + executions: 2 # configure a tracer # there are few examples, such zipkin diff --git a/pom.xml b/pom.xml index 951a4d2..116f602 100644 --- a/pom.xml +++ b/pom.xml @@ -79,6 +79,23 @@ + + maven-assembly-plugin + 2.5.3 + + src/assembly/dep.xml + + + + create-archive + package + + single + + + + + diff --git a/rmjvm.sh b/rmjvm.sh new file mode 100644 index 0000000..865c95f --- /dev/null +++ b/rmjvm.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +java -jar rmjvm-jar-with-dependencies.jar "$@" \ No newline at end of file diff --git a/src/assembly/dep.xml b/src/assembly/dep.xml new file mode 100644 index 0000000..2d5218e --- /dev/null +++ b/src/assembly/dep.xml @@ -0,0 +1,34 @@ + + bin + + tar.gz + tar.bz2 + zip + + + + ${project.basedir} + / + + README* + LICENSE* + bin/* + NOTICE* + conf/rmjvm.yml + + + + ${project.build.directory} + / + + *.jar + + + + ${project.build.directory}/site + docs + + + \ No newline at end of file diff --git a/src/main/java/com/bmdsoftware/monitor/resourcemonitor/memory/imp/MemoryCheckImp.java b/src/main/java/com/bmdsoftware/monitor/resourcemonitor/memory/imp/MemoryCheckImp.java index f2c9e86..f3328bc 100644 --- a/src/main/java/com/bmdsoftware/monitor/resourcemonitor/memory/imp/MemoryCheckImp.java +++ b/src/main/java/com/bmdsoftware/monitor/resourcemonitor/memory/imp/MemoryCheckImp.java @@ -105,8 +105,9 @@ public void monitor() throws IOException { String fileName = "heap_dump_" + new SimpleDateFormat("dd.MM.yyyy HH.mm.ss").format(new Date()) + ".hprof"; boolean onlyLiveObjects = false; bean.dumpHeap(fileName, onlyLiveObjects); + File heapFile = new File(nameHeapFile + fileName); - heap = HeapFactory.createFastHeap(new File(nameHeapFile + fileName)); + heap = HeapFactory.createFastHeap(heapFile); MemoryAnalysisUtil.heap = heap; @@ -185,6 +186,11 @@ public void monitor() throws IOException { System.out.println("average memory usage is: " + tempMemory / sampleCount);//print average memory usage this.totalMemory = tempMemory / sampleCount; jmxc.close(); + heap = null; + MemoryAnalysisUtil.heap = null; + System.out.println("Delete the following heap: " + heapFile.getAbsolutePath()); + heapFile.deleteOnExit(); + System.out.println("Heap exists: " + heapFile.exists()); } diff --git a/src/test/java/TestMemoryMonitor.java b/src/test/java/TestMemoryMonitor.java index a1d652d..b2671c0 100644 --- a/src/test/java/TestMemoryMonitor.java +++ b/src/test/java/TestMemoryMonitor.java @@ -59,20 +59,22 @@ void testMemoryConnection() throws IOException, MalformedObjectNameException { JMXConnection con = null; try { con = new JMXConnection("service:jmx:rmi:///jndi/rmi://" + hostName + ":" + portNum + "/jmxrmi"); + + + // Create a temporary directory + //File myTempDir = Files.createTempDir(); + Path tempDirWithPrefix = Files.createTempDirectory("rmjvm-"); + + MemoryMonitor monitor = new MemoryMonitor(con); + monitor.initHeapDump(new File("c:/Users/bastiao/Projects/dicoogle/dicoogle/target/")); + String report = monitor.reportStrings(); + String hist = monitor.printHistogram(); + System.out.println(hist); } catch (Exception e){ return; } - // Create a temporary directory - //File myTempDir = Files.createTempDir(); - Path tempDirWithPrefix = Files.createTempDirectory("rmjvm-"); - - MemoryMonitor monitor = new MemoryMonitor(con); - monitor.initHeapDump(new File("c:/Users/bastiao/Projects/dicoogle/dicoogle/target/")); - String report = monitor.reportStrings(); - String hist = monitor.printHistogram(); - System.out.println(hist); }