Results 1 to 3 of 3
  1. #1
    zzpprk is offline Member
    Join Date
    Aug 2009
    Rep Power

    Default Memory Allocation


    I wonder if one of you knows the answer to the below.

    When you start a JVM, you can specify the maximum amount of memory it will use (i.e. that will be available to the application it will run). On Win32 systems, this amount of memory has to be in a single block. In other words, the JVM will use an amount of memory less than or equal to the value you specify at startup.

    Is there any way to find-out what this value actually is?

    Does anybody know if there are Java libraries that can defrag the system memory? I need the maximum I can get so I would like to defrag the RAM before launching my application. I plan to use a seperate JVM to do that so my launch sequence will look something like the below.

    1) Start small JVM + App to defrag RAM and report the amount available
    2) Launch big JVM + Main App

    Any comments are much appreciated.



  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Rep Power


    To find out how much memory is available to your application, use

    Java Code:
    public long Runtime.getRuntime().totalMemory()

  3. #3
    iluxa is offline Senior Member
    Join Date
    Mar 2010
    Rep Power


    Like you said, JVM only gets access to the block of memory it had been handed by the OS. It would therefore very much surprise me if the OS allowed you to defragment the RAM (that would require the JVM to have access to ALL RAM, wouldnt it). You'd have to use some native utility.

Similar Threads

  1. Array memory allocation
    By number5isalive in forum Advanced Java
    Replies: 8
    Last Post: 10-14-2009, 09:04 AM
  2. Memory Allocation
    By kishan in forum New To Java
    Replies: 3
    Last Post: 09-19-2009, 06:47 PM
  3. Resource management allocation
    By jyothi.priyanka in forum New To Java
    Replies: 0
    Last Post: 04-04-2009, 02:25 PM
  4. Replies: 2
    Last Post: 08-21-2008, 08:33 PM
  5. Out of memory
    By mew in forum New To Java
    Replies: 1
    Last Post: 01-20-2008, 09:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts