Mapping set heap sizes to used memory

Hi all,
I've got a question about the parameters used to control your java process' heap sizes: "-Xms128m -Xmx256m" etc.
Let's say I set my min and max to 2Gb, just for a simplistic example.
If I then look at the linux server my process is running on, I may see a top screen like so:
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
10647 javaprog 20   0 2180m 1.9g  18m S  1.3  3.7   1:57.02 javaWhat I'm trying to understand is what relationship - if any - there is between these arguments and the figures I see within top. One thing in particular that I'm interested in is the fact that I occasionally see a RES (or more commonly a VIRT) size higher than the maximum that I have provided to Java. Naively I would assume that therefore there isn't a relationship between the two... but I wouldn't mind someone clarifiying this for me.
Any resources on the matter would be appreciated, and I apologise if this question is outside the realms of this particular subforum.
Dave.

Peter Lawrey wrote:
user5287726 wrote:
Peter Lawrey wrote:
It will always reserve this much virtual memory, plus. In term of resident memory, even the minimum is not guarenteed to be used. The minimum specifies at what point it will make little effort to recycle memory. i.e. it grows to the minimum size freely, but a "Hello World" program still won't use the minimum size.No, Linux does not reserve virtual memory. Just Google "Linux memory overcommit". Out-of-the-box, every Linux distro I'm aware of will just keep returning virtual memory to processes until things fall apart and the kernel starts killing processes that are using lots of memory - like your database server, web server, or application-critical JVMs. You know - the very processes you built and deployed the machine to run. Just Google "Linux OOM killer".Thats not the behaviour I see. When I start a process which busy waits, but doesn't create any objects, the virtual memory sized used is based on the -mx option, not how much is used. Given virtual memeory is largely free, why would an OS only give virtual memory on an as needs basis.
Busy looping process which does nothing.
In each case the resident size is 16m
option       virtual size
-mx100m      368m = 100m + 268m
-mx250m      517m = 250m + 267m
-mx500m      769m = 500m + 269m
-mx1g        1294m = 1024m + 270m
-mx2g        2321m = 2048m + 273mTo me it appears that the maximum size you ask is immediately added to the virtual memory size, even if its not used (plus an overhead) i.e. the resident size is only 16m.Yes, it's only using 16m. And its virtual size may very well be what you see. But that doesn't mean the OS actually has enough RAM + swap the hold what it tells all running processes they can have.
How much RAM + swap does your machine have? Say it's 4 GB. You can probably run 10 or 20 JVMs simultaneously with the "-mx2g" option. Imagine what happens, though, if they actually try and use that memory - that the OS said they could have, but which doesn't all exist.
What happens?
The OOM killer fires up and starts killing processes. Which ones? Gee, it's a "standard election procedure". Which on a server that's actually doing something tend to be the processes actually doing something, like your DBMS or web server or JVM. Or maybe it's your backups that get whacked because they're "newly started" and got promised access to memory that doesn't exist.
Memory overcommit on a server with availability and reliability requirements more stringent than risible is indefensible.

Similar Messages

  • Reducing app size and using memory

    Building with release preference Blank App template will give you a ~200kb .exe, which in running state use ~7mb of memory.
    It has a huge list of external dependencies.
    So, is it possible to reduce app size and using memory?
    Or, how safely unlink from app headers that really didnt used?

    generally speaking  premature optimization is not a good idea.
    Normally those tricks we learned from stone age are picked by tools already.
    (http://stackoverflow.com/questions/6215782/do-unused-functions-get-optimized-out)
    So if you experice performance/optimization issue
    optimization ususally goes with repeated measure -> optimize -> verify
    cycles.

  • Benefit of setting heap size

    Hello sir,
    what is the benefit of setting heap size in java....?
    java -Xms40m -Xmx80m <program name>

    benefit of setting heap sizeIt is not for the benefit! It is for the need!!
    If you are encountering java.lang.OutOfMemoryError, then you can avoid this error, by setting heap size as reasonable.

  • Setting heap size

    I hope you will all forgive me because this has been exhausted although I followed all the advices.
    After the following examples, to check my own environment. I have done the following:
    long heapSize = Runtime.getRuntime().totalMemory();
        System.out.println(heapSize);
        // Get maximum size of heap in bytes. The heap cannot grow beyond this size.
        // Any attempt will result in an OutOfMemoryException.
        long heapMaxSize = Runtime.getRuntime().maxMemory();
        System.out.println(heapMaxSize);
        // Get amount of free memory within the heap in bytes. This size will increase
        // after garbage collection and decrease as new objects are created.
        long heapFreeSize = Runtime.getRuntime().freeMemory();
        System.out.println(heapFreeSize);
            Which outputs is:
    5177344
    66650112
    4437824
    Currently, it looks like my heap cannot grow more than 6.6M right?
    Now if I want to increase my maximum heap size, the command is adviced to be:
    java -Xmx128m readFile.class
    However, it keeps coming oout with an error:
    Exception in thread "main" java.lang.NoClassDefFoundError: readFile/class
    Where did that "main" come from? The only thing that I have done is that I have another class called myMain which calls this clss for test purposes.
    The class which raised this heap problem was a class I was using to read files as in the bellow:
    import java.io.*;
    import java.util.*;
    import java.util.regex.*;
    public class readFile
    private ArrayList<String>  dataFromFile= new ArrayList<String>();
        public String readFile(String fileNameIn, String encoding) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(
          new FileInputStream(fileNameIn), encoding));
          buffer = new StringBuffer();
        int i;
        while((i = in.read()) != -1) buffer.append((char)i);
        in.close();
        return buffer.toString();
    //return an array of each data read from file separated by a tab etc
      public ArrayList<String> getRecords(String fileNameIn) throws IOException {
          String  s = this.readFile(fileNameIn);
          String current;
          Pattern p = Pattern.compile("[^\t\n]+|\t(?=\t)|\t$",
          Pattern.CASE_INSENSITIVE);
          Matcher m = p.matcher(s);
          while(m.find()){
             current = m.group(0).trim();
             dataFromFile.add(current);
            }//while 
        return dataFromFile;
    }Message was edited by:
    McTaar
    Message was edited by:
    McTaar

    This is the error displayed:
    java.lang.OutOfMemoryError: Java heap space
         at java.util.Arrays.copyOf(Arrays.java:2760)
         at java.util.Arrays.copyOf(Arrays.java:2734)
         at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
         at java.util.ArrayList.add(ArrayList.java:351)
         at readFile.getRecords(readFile.java:41)
         at myMain.main(myMain.java:79)readFile: 41 is
    dataFromFile.add(current);

  • Unable to set heap size to 4gb in sun java application server pe 8.2

    i have sun v890 machine with 32gb ram and solaris 10
    i am running sun java system application server platform edition 8.2
    when i am setting max heap size to 4GB
    it is giving an error
    Invalid maximum heap size -Xmx4096m
    the specified size exceeds the maximum representable size
    i want to know what i should do to increase this heap size.
    also tell me if the JVM running is 64bit. if not how can i change it
    to 64bit VM.

    The maximum size for a 32-bit process on Solaris (any 32-bit process, not just Java) is 4GB, which includes the program text, thread stacks, and various other things in addition to the JVM heap. So the maximum heap you can expect to allocate for the appserver is about 3500MB.
    SJSAS 8.2 does not support a 64-bit JVM; SJSAS 9.1 is needed for that. However, it's very rare that a Java EE application actually needs that much memory, and the 64-bit JVM has a performance penalty vs. the standard JVM. So more heap is probably not going to make your app run any better.

  • Setting heap size through oracleAS 10.1.3 enterprise manager

    Hi All,
    Can any body pls tell me how we can set java heap size through oracleAS 10.1.3 enterprise manager
    Best Regards
    Girish Tandel

    hi...
    Yes, we can set the heap size in opmn.xml file in java-options.... But this is not the good practice to mannualy edit server xml files. In OracleAS 10.1.2 we can set the same through OEM. But i am not able to set using oem in oracleas 10.1.3
    Best Regards
    Girish

  • Set heap size websphere

    Hello
    i was playing around with websphere and increased the heap size from 3072 to 5072. Now when i tried to restart the server...it wont come back up. I cant getinto the Websphere administrative console either. does any one know a way to set the heap size thru command line back to 3072 for this server?
    thanks!

    http://www-1.ibm.com/support/docview.wss?rs=180&context=SSEQTP&dc=DB520&uid=swg21164724&loc=en_US&cs=utf-8&lang=en

  • Default Heap Size when using jmsc.dll

    We have had some crashes using Weblogic JMS (v 11.x) with one of our C-API apps.
    How can I find out the xmx size being used by Java?

    If you turn on JMSDEBUG (by setting it to 'y') the JMS C API may print out the JVM options. The log messages will go to the files started with "ULOG" in the directory where your app runs from. You can change the location by setting the ULOGPFX variable in your client environment.
    You can override the JVM settings with JMSJVMOPTS variable.
    Hope this helps.

  • Setting Heap Size from JAR

    Hi,
    Does anybody know here how to specify the Heap size with JAR.
    From command line, I type java -jar -ms128M -mx350M IzoneIDE.jar
    My jar file is executable, so how can I specify the heap size in Jar Files.
    Please dont comment this as a Cross Post as I dont find any answer in Java Programming forum, thats why I post it here.
    Thanks
    Raheel

    Check here, http://java.sun.com/docs/books/tutorial/jar/
    not sure if the right info is there, but If you do find it pls let us know.
    ICE

  • Setting array size, effect on memory

    Does setiing the array size to a huge no has any affect on the memory, performance and is it considered good programming. If not what are the other options?
    String [] arrayString = new String [2354];

    Your question is rather ambiguously worded.
    In Java arrays cannot be resized, so you should set the array to the exact size you need. If you need a huge array, create one. If you need a small array, create one. If you don't know how large it should be, or need it to be dynamically sized, use any of these great classes - ArrayList, HashMap, HashSet, etc... Try reading the Java API documentation on these classes...
    And yes, when you create a huge array, it actually allocates the space for each element in the array right then, and in fact initializes each with the default values of null, zero, or false depending on the type of the array.

  • Set heap size for applet

    I know that it is not allowed programmatically but what is syntex of the command to set max jvm. Which class name muste given in the command. I tried :
    java -Xmx128m
    if I write just like that, a screen shows as I write -help.
    Thank you

    I suspect you can't
    anything like that is restricted as it allows you
    access to the system.
    this prevents against the possibility overflow.
    though having said that , I don't know much about native methods in JAVA.

  • How to monitor heap size used in OPP in order to protect Out of Memory

    My objective is to know how much heap size currently use so I can handle or do something before user got error report.
    The following sql statement just determine what the heap size per OPP process is currently setting:
    select DEVELOPER_PARAMETERS from FND_CP_SERVICES
    where SERVICE_ID = (select MANAGER_TYPE from FND_CONCURRENT_QUEUES
    where CONCURRENT_QUEUE_NAME = 'FNDCPOPP');
    Now OPP heap size is set to 1.5G.
    Thanks

    Hi Sam,
    Please review the following note, as it might help you!!!
    Tuning Output Post Processor (OPP) to Improve Performance (Doc ID 1399454.1)
    R12: How to Configure the Account Analysis Report for Large Reports (Doc ID 737311.1)
    Thanks &
    Best Regards,

  • Plz can you help me. How to increase the Heap Size!!!!!!!!!!!

    Hi,
    i'm new to 10g appl server
    Failed to deploy web application "AGXI51". Failed to deploy web application "AGXI51". . The evaluate phase failed. The Adapter used in the evaluate may have thrown an exception.
    Resolution:
    Please call Oracle support.
    Base Exception:
    java.lang.OutOfMemoryError
    null. java.lang.OutOfMemoryError
    i'm getting this Error while deploying the application.So wat is the procedure to increase the Heap Size
    Regards,
    Niranjan.D

    Locate opmn.xml on your instance. In file locate section relevant for container you use (i.e. "home"). In next line you can see tags where startup parameters are set. You should add following parameters (this will set heap size on 512Mb)
    -Xms512m -Xmx512m
    For detailed explanation I would recommend you to check following link:
    http://download-uk.oracle.com/docs/cd/B25221_03/web.1013/b14431/troublesht.htm
    Hope this help.

  • Heap Size in 64 bit operating systems

    Hi,
    I have written a Java application which needs huge size heap. I tried to run the application under 32 bit windows operating system, but with 32 bit OS I got maximum heap size of 1.5 GB. To get more heap I have installed Windows 2003 Standard edition 64 bit version. Also I have installed JDK 1.7 64 bit for windows. I am using Netbeans IDE 6.7. I have configured Netbeans for 64 bit JVM. With this configuration I tried to set heap size of 1.6 GB it gives error "Could not create Java Virtual machine......". Also If I check proceess in task manager I see java.exe * 32 process. Does this mean JVM being used is still 32 bit JVM?
    Please let me know how to get more heap size under 64 bit OS?
    Regards,
    -Suresh Shirgave

    From a cmd window run a simple program using a 64-bit jvm (HelloWorld or similar) with different -Xmx values to establish the limit at which the program will run.
    <pathTo64-bitJVM>java -Xmxnn HelloWorldIf that's different from NB, then it's a setting of some kind in NB. Maybe you are pointing NB to a 32-bit JDK? Check the value in <NBInstallDirectory>\etc\netbeans.conf. If that's not it, check NB Help. You might want to ask the question at a NB forum, since this is a new version there may be a problem. Note that these forums are for Java language topics.

  • Retrieve Heap size from program

    Hi, i searched the foruns with "get heap size" and "retrieve size"
    and i also checked the System.getProperty(String key) string keys at
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperty(java.lang.String)
    and havent found a method to retrieve the currently set heap size.
    Is there a way to do this?
    My program needs to initialize something based on how large the
    user set the heap size (using the command line -Xms32m -Xmx128m...)
    Any info would be appreciated! Thanks alot!

    Touche!
    Thanks alot you pointed me in exactly the right direction.
    When i did research on java.lang.Runtime
    i found this post
    http://forums.java.sun.com/thread.jspa?threadID=529065&start=0&tstart=165
    which is a great two page thread on this subject.
    Runtime
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#maxMemory()

Maybe you are looking for

  • How to print an html report?

    In a Test UUT's execution, the process model generates and saves a html report. How can add steps to the process model to print the report each time? I'm thinking maybe somehow using an ActiveX call to open IE and then print (1 step or 2?), but I'm a

  • Cannot load css files into osgi bundle

    I want to create JavaFX application based on several osgi bundles. I use Felix framework for osgi container. I face the same issue as this post Exception logged when using custom css in JavaFX in Felix OSGI How I can set globally -Dbinary.css=false I

  • MBP problem

    I just bought my MBP couple of days ago and i was shocked how lousy the WIFI is i cant join most of the networks in range and i can only join networks with 0 Security!! whats the problem?! please help me any solution for that i tried everything in th

  • Tables containing user details.

    Hi, Which table can I use to view all the users available on the SAP system and their details e.g. Username, user's contact details and etc. Regards, Thandi

  • AVCHD-Lite no sound

    Hello, I have a problem with the file type  AVCHD-Lite. When I open a file in photoshop elements 11, I can watch the video but there is no sound. I have already installed the latest version of quicktime, but this didn't help. Thank you for your help