I have a java application. The issue now I take a heap using the jmap and I also got this codes running in my application.Both are giving me different values. The runtime is showing out of 256mb
which is what I have assigned as initial and maximum memory? I want to detect is there any memory leakage but the runtime is fluctuating and whereas the one from heap is keep increasing in small amount? Any help on this?
long memory = runtime.totalMemory() - runtime.freeMemory();
System.out.println("\n\nUsed memory is bytes: " + memory);
//Print the jvm heap size.
long heapSize = runtime.totalMemory();
System.out.println("\n\nHeap Size = " + heapSize);
int mb = 1024*1024;
System.out.println("##### Heap utilization statistics [MB] #####");
//Print used memory
System.out.println("Used Memory:" + (runtime.totalMemory() - runtime.freeMemory()) / mb);
//Print free memory
System.out.println("Free Memory:" + runtime.freeMemory() / mb);
//Print total available memory
System.out.println("Total Memory:" + runtime.totalMemory() / mb);
//Print Maximum available memory
System.out.println("Max Memory:" + runtime.maxMemory() / mb);