File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Java Memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Memory" Watch "Java Memory" New topic
Author

Java Memory

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 743
Hi, can someone explain how the java memory works, below is what I've got:

FREE MAX TOTAL

I added an array of 44,703,332 strings to program, and I got a 'heap space error'
Using 44,703,331 gives the TOTAL the same as the MAX.
So thats quite clear.

But my free memory is still 75M, intuitively I would have thought FREE+TOTAL = MAX
so in my example above, you would expect the FREE to be 0, but its 75M instead.

So its not as simple as I thought, can anyone explain how the 3 values relate to each other.

Thanks
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Runtime.freeMemeory() returns an approximation to the total amount of memory currently available for future allocated objects, measured in bytes.
Runtime.totalMemory() returns the total amount of memory in the Java virtual machine. The value returned by this method may vary over time, depending on the host environment.
Runtime.maxMemory() is proabaly the only 'fixed' value.

As I see it, these values correlate somewhat loosly and there is no formula for it that would work all the time (if ever).


SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Mukesh Ranjan
Greenhorn

Joined: Jun 24, 2009
Posts: 22
Which exception you are getting exxactly,

Check if it OutOfMemory Exception or StackOverflowException,

If you are doing it inside some thread or if it is a local variable then try to look for stack size, rather than heap size..


For more detail you can look at site: www.pourbrain.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Memory
 
Similar Threads
memory impact on statement
Garbage Collection Help!
Free memory: Total memory: Max memory:
Help regarding Runtime.java
Size of a empty class