hello
What is meant by heap size in JVM? and how to set HeapSize in jsp also i would like to know how much heap size can be increased in my JSP also tell me what is the best way to measure the utilization of each JVM .
thank you.
Printable View
hello
What is meant by heap size in JVM? and how to set HeapSize in jsp also i would like to know how much heap size can be increased in my JSP also tell me what is the best way to measure the utilization of each JVM .
thank you.
The heap is kind of memory where JAVA creates new objects.normally a heap is located directly after the code section .heap size is the size of JVM, typically set using -Xmx or -Xms paramters
-Xmx - sets max head size
-Xms - set startup heap size
try this in JBoss_home/bin/run.conf
set size that you wantQuote:
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
fi
check this Simple heap size monitor
simple to use:Quote:
public class MemoryMonitorHelper extends Thread (
private static MemoryMonitorHelper _instance = null;
private static MemoryMonitorHelper getInstance () (
if (_instance == null) (
_instance = new MemoryMonitorHelper ();
)
return _instance;
)
public static void startMonitoring (File file, String title) (
startMonitoring (file, title, 1);
)
public static void startMonitoring (File file, String title, double refreshInSec) (
System. Out. Println ( "Start Monitoring");
MemoryMonitorHelper i = getInstance ();
i. SetFile (file);
i. setTitle (title);
i. setRefreshInSec (refreshInSec);
i. start ();
)
public static void stopMonitoring () (
System. Out. Println ( "Stop Monitoring");
getInstance (). finish ();
)
private File file = null;
private String title = null;
private double refreshInSec = 1. 0;
private boolean enabled = false;
public MemoryMonitorHelper () (
)
public void SetFile (File file) (
this. file = file;
)
public void setRefreshInSec (double refreshInSec) (
this. refreshInSec = refreshInSec;
)
public void setTitle (String title) (
this. title = title;
)
private String getSize (double size) (
String [] (suffix =
"B", "K", "M", "G"
);
if int = 0;
while (size> 1024) (
size / = 1024;
if + +;
)
return DoubleHelper. format (size, "#,## 0.00 ") + suffix [if];
)
public void run () (
enabled = true;
while (enabled) (
long total = Runtime. getRuntime (). totalMemory ();
long free = Runtime. getRuntime (). freeMemory ();
String data = "[" + DateHelper. GetFormattedDate ( "yy / MM / dd HH: mm: ss") + "]" +
title + "=> total:" + getSize (total) +
"Free:" + getSize (free) +
"" + DoubleHelper. Format (((double) free / (double) total * 100. 0), "# 0") + "%";
System. Out. Println (data);
try (
FileHelper. CreateContent (file, data + "\ n", true, FileHelper. UTF8);
sleep ((int) (refreshInSec * 1000));
) Catch (Exception e) (
e. printStackTrace ();
enabled = false;
)
)
)
public synchronized void finish () (
enabled = false;
)
)
Quote:
public static void main (String [] args) (
boolean heap = (args. length> 0) & & args [0]. equals ( "HEAP");
if (heap) (
MemoryMonitorHelper. StartMonitoring (new File ( "mem.log"), "MyProcess");
)
/ *- -* Processes /
if (heap) (
MemoryMonitorHelper. StopMonitoring ();
)
)