Results 1 to 4 of 4

Thread: Heap size in JVM and Setting max Heap Size for the JVM

  1. #1
    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.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    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

  3. #3
    Join Date
    Oct 2005
    Posts
    2,358

    Re: Heap size in JVM and Setting max Heap Size for the JVM

    try this in JBoss_home/bin/run.conf
    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

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Heap size in JVM and Setting max Heap Size for the JVM

    check this Simple heap size monitor

    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:

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

Similar Threads

  1. How To Increase Heap Size In Java
    By Linoo in forum Software Development
    Replies: 5
    Last Post: 16-02-2010, 06:33 PM
  2. Heap Space Error in Java
    By Taylor D in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 09:57 AM
  3. Need Help in Heap Code in C++
    By Pratim in forum Software Development
    Replies: 5
    Last Post: 21-01-2010, 05:57 PM
  4. What is Heap and Stack?
    By samualres in forum Software Development
    Replies: 5
    Last Post: 27-11-2009, 10:56 AM
  5. Difference between heap and stack
    By KADEEM in forum Software Development
    Replies: 3
    Last Post: 04-09-2009, 09:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,501,818.65275 seconds with 16 queries