Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 19-05-2009
Member
 
Join Date: Jan 2009
Posts: 52
Heap size in JVM and Setting max Heap Size for the JVM

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.
Reply With Quote
  #2  
Old 19-05-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: Heap size in JVM and Setting max Heap Size for the JVM

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
Reply With Quote
  #3  
Old 19-05-2009
Member
 
Join Date: Oct 2005
Posts: 2,357
Re: Heap size in JVM and Setting max Heap Size for the JVM

try this in JBoss_home/bin/run.conf
Quote:
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
fi
set size that you want
Reply With Quote
  #4  
Old 19-05-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: Heap size in JVM and Setting max Heap Size for the JVM

check this Simple heap size monitor

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;
)

)
simple to use:

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 ();
)
)
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Heap size in JVM and Setting max Heap Size for the JVM"
Thread Thread Starter Forum Replies Last Post
How To Increase Heap Size In Java Linoo Software Development 5 16-02-2010 06:33 PM
Heap Space Error in Java Taylor D Software Development 5 29-01-2010 09:57 AM
Need Help in Heap Code in C++ Pratim Software Development 5 21-01-2010 05:57 PM
What is Heap and Stack? samualres Software Development 5 27-11-2009 10:56 AM
Difference between heap and stack KADEEM Software Development 3 04-09-2009 09:07 PM


All times are GMT +5.5. The time now is 07:58 PM.