Heap and Memory Footprint
7 Message(s) by 4 Author(s) originally posted in java machine
| From: parmindersk |
Date: Wednesday, May 30, 2007
|
I used JProf to see that my Swing
app has 40 megs of
heap allocated to
it. However, over time VM size of the JAVA.exe
process keeps on rising
and at times hits 300 megs. I understand that the
JVM may be using
this
memory for internal purposes. But is there a way to limit the
size to which the VM grows?
In short if I need to tell my customers that when they
run my app the
VM size won't grow higher than some limit. Are there any VM
parameter s I can use to ensure this.
| From: Joshua Cranmer |
Date: Wednesday, May 30, 2007
|
wrote in message:
I used JProf to see that my Swing app has 40 megs of heap allocated to
it. However, over time VM size of the JAVA.exe process keeps on rising
and at times hits 300 megs. I understand that the JVM may be using
this memory for internal purposes. But is there a way to limit the
size to which the VM grows?
In short if I need to tell my customers that when they run my app the
VM size won't grow higher than some limit. Are there any VM
parameters I can use to ensure this.
From Sun's JAVA
command line reference (keep in mind: this is a
'non-standard' option, and is only guaranteed for JAVA
version s ~ 1.1 - 6):
-Xmxn
Specify the maximum size, in bytes, of the memory allocation pool.
This value must a multiple of 1024 greater than 2MB. Append the letter k
or K to indicate kilobytes, or m or M to indicate megabytes.
(e.g. -Xmx40m)
This is the
URL for the JAVA 6 version of the command line:
http://JAVA.sun.com/JAVAse/6/docs/technotes/tools/windows/JAVA.html#nonstandard
and the earlier versions can be obtained by changing the JAVAse/6/ to
j2se/1.{5,4.2,?}/
| From: parmindersk |
Date: Thursday, May 31, 2007
|
I did that, but that does not help. I set the size to 64 megs. but the
VM size behaved the same way. Please let me know if there's something
else that can be done.Also, can you please
point me to the
diff between the VM size and the
heap size?
wrote in message:
wrote in message:
> I used JProf to see that my Swing app has 40 megs of heap allocated to
> it. However, over time VM size of the JAVA.exe process keeps on rising
> and at times hits 300 megs. I understand that the JVM may be using
> this memory for internal purposes. But is there a way to limit the
> size to which the VM grows?
> In short if I need to tell my customers that when they run my app the
> VM size won't grow higher than some limit. Are there any VM
> parameters I can use to ensure this.
From Sun's JAVA command line reference (keep in mind: this is a
'non-standard' option, and is only guaranteed for JAVA versions ~ 1.1 - 6):
-Xmxn
Specify the maximum size, in bytes, of the memory allocation pool.
This value must a multiple of 1024 greater than 2MB. Append the letter k
or K to indicate kilobytes, or m or M to indicate megabytes.
(e.g. -Xmx40m)
This is the URL for the JAVA 6 version of the command line:
http://JAVA.sun.com/JAVAse/6/docs/technotes/tools/windows/JAVA.html#n...
and the earlier versions can be obtained by changing the JAVAse/6/ to
> j2se/1.{5,4.2,?}/
| From: hbdere |
Date: Saturday, June 02, 2007
|
On May 31, 8:51 pm, "parminde...@xxxxxxxxxxx"
<parminde...@xxxxxxxxxxx>
wrote in message:
I did that, but that does not help. I set the size to 64 megs. but the
VM size behaved the same way. Please let me know if there's something
else that can be done.
Also, can you please point me to the diff between the VM size and the
heap size?
I can only do some guesswork, but it should be like this: the heap is
the memory where the JAVA
program running inside the VM may allocate
object s. Together with the stack, it limits the amount of memory the
JAVA program may consume. So, by using -Xmx (and -Xms), you may modify
this amount of memory; and judging from your description of JProf this
already works fine.
However, the
virtual machine needs memory for itself - this should
include loaded
class files, but may also contain hotspot-compiled
code, garbage collection
data and such things. If your application is
really, really big (like a Spring web application which requires about
20 JAR files, each a few MB big) it doesn't seem too unlikely that
your VM requires so much memory.
There are OS-dependent ways of limiting the memory a single
application may consume. For Linux, using a
csh shell gives you the
"limit" command (see "man csh" for the syntax) that allows you to
limit memory usage of any process. However, whether this will keep the
VM from crashing is another question; if it is just
caching some data,
it may be forced to cope with the tighter memory limit, but if it
really needs memory that big, you are lost, as there isn'thing you
can do (besides checking out other VM, like the
BEA JRockit engine,
which might be a little more sensible towards those issues - but
again, I am just guessing.)
Regards,
H.
| From: David Gourley |
Date: Monday, June 04, 2007
|
wrote in message:
I did that, but that does not help. I set the size to 64 megs. but the
VM size behaved the same way. Please let me know if there's something
else that can be done.
Also, can you please point me to the diff between the VM size and the
heap size?
One additional thing you might want to look out for. If you've any
mixed
language objects (i.e. JAVA objects which have underlying native
memory associated), when the object is created memory is allocated in
both the JAVA heap and the C native heap. The JAVA heap is
control led
by the max heap size parameter, but the C memory is simply allocated
using
malloc (and causes the JVM to grow). Typically such objects have
a manual tidy
method (often close()), with a fallback of object
finalisation. It is important to explicitly call close() - otherwise if
the object gets promoted to the old area, the memory won't be freed
until the object gets garbage collected from the old area which can take
a very, very long time (and in the worst case you may have the process
hit a memory limit without a garbage collection occurring as only the
JAVA heap's behaviour will
trigger garbage collection).
There are examples of such objects in the JAVA
library (e.g. some of the
InputStream and OutputStream classes), as well as many 3rd party
libraries (e.g. I have seen it with database
cursor implementations).
So in general, if a class has a close()
type method, it must always be
explicitly called, and in a finally
block (so that exceptions do not
cause leaked resources).
Cheers
Dave
wrote in message:
wrote in message:
I used JProf to see that my Swing app has 40 megs of heap allocated to
it. However, over time VM size of the JAVA.exe process keeps on rising
and at times hits 300 megs. I understand that the JVM may be using
this memory for internal purposes. But is there a way to limit the
size to which the VM grows?
In short if I need to tell my customers that when they run my app the
VM size won't grow higher than some limit. Are there any VM
parameters I can use to ensure this.
From Sun's JAVA command line reference (keep in mind: this is a
'non-standard' option, and is only guaranteed for JAVA versions ~ 1.1 - 6):
-Xmxn
Specify the maximum size, in bytes, of the memory allocation pool.
This value must a multiple of 1024 greater than 2MB. Append the letter k
or K to indicate kilobytes, or m or M to indicate megabytes.
(e.g. -Xmx40m)
This is the URL for the JAVA 6 version of the command line:
http://JAVA.sun.com/JAVAse/6/docs/technotes/tools/windows/JAVA.html#n...
and the earlier versions can be obtained by changing the JAVAse/6/ to
j2se/1.{5,4.2,?}/
| From: parmindersk |
Date: Friday, June 08, 2007
|
wrote in message:
wrote in message:
> I did that, but that does not help. I set the size to 64 megs. but the
> VM size behaved the same way. Please let me know if there's something
> else that can be done.
> Also, can you please point me to the diff between the VM size and the
> heap size?
One additional thing you might want to look out for. If you've any
mixed language objects (i.e. JAVA objects which have underlying native
memory associated), when the object is created memory is allocated in
both the JAVA heap and the C native heap. The JAVA heap is controlled
by the max heap size parameter, but the C memory is simply allocated
using malloc (and causes the JVM to grow). Typically such objects have
a manual tidy method (often close()), with a fallback of object
finalisation. It is important to explicitly call close() - otherwise if
the object gets promoted to the old area, the memory won't be freed
until the object gets garbage collected from the old area which can take
a very, very long time (and in the worst case you may have the process
hit a memory limit without a garbage collection occurring as only the
JAVA heap's behaviour will trigger garbage collection).
There are examples of such objects in the JAVA library (e.g. some of the
InputStream and OutputStream classes), as well as many 3rd party
libraries (e.g. I have seen it with database cursor implementations).
So in general, if a class has a close() type method, it must always be
explicitly called, and in a finally block (so that exceptions do not
cause leaked resources).
Cheers
Dave
wrote in message:
wrote in message:
>I used JProf to see that my Swing app has 40 megs of heap allocated to
>it. However, over time VM size of the JAVA.exe process keeps on rising
>and at times hits 300 megs. I understand that the JVM may be using
>this memory for internal purposes. But is there a way to limit the
>size to which the VM grows?
>In short if I need to tell my customers that when they run my app the
>VM size won't grow higher than some limit. Are there any VM
>parameters I can use to ensure this.
From Sun's JAVA command line reference (keep in mind: this is a
'non-standard' option, and is only guaranteed for JAVA versions ~ 1.1 - 6):
-Xmxn
Specify the maximum size, in bytes, of the memory allocation pool.
This value must a multiple of 1024 greater than 2MB. Append the letter k
or K to indicate kilobytes, or m or M to indicate megabytes.
(e.g. -Xmx40m)
This is the URL for the JAVA 6 version of the command line:
http://JAVA.sun.com/JAVAse/6/docs/technotes/tools/windows/JAVA.html#n...
and the earlier versions can be obtained by changing the JAVAse/6/ to
j2se/1.{5,4.2,?}/
Thanks H and Dave.
So, in a nutshell, there's no way we can control the VM size, correct?
| From: David Gourley |
Date: Monday, June 11, 2007
|
wrote in message:
Thanks H and Dave.
So, in a nutshell, there's no way we can control the VM size, correct?
Depends at what level you want to control it.
On some UNIX variants you can use
kernel parameters or other mechanisms
to force a process to
core dump if various memory areas (e.g. data
segment) exceeds a certain size. This can stop the process from growing
to a point where
paging is occurring.
If a JVM is growing mysteriously, if there is an equivalent of
Solaris
pmap on your OS, it may be worth understanding which area of memory is
growing as you might be able to stop it.... (e.g. is it because of too
many threads, or a growing native heap etc.)
But no command line parameter I'm afraid....
Dave
Next Message: Manipulate JAVA thread stack in this way
Blogs related to Heap and Memory Footprint
Tuning Garbage Collection(1)
Footprint is the working set of a process, measured in pages and cache lines. On systems with limited physical
memory or many processes,
footprint may dictate scalability. Promptness is the time between when an object becomes dead and
...
Java performance on Niagara platform
Depending on the
heap size, the performance difference between 4M and 256M pages might not be substantial for some applications - but there might be a big difference in the
memory footprint with 4M and 256M pages. Due to this,
Java SE
...
A design standard for mobile gaming is definitely needed
... the lack of
footprint available. There is also an issue with the actual capabilities of each individual platform. While seemingly similar, each handset platform has subtle and often major differences in screen size,
heap memory, IO,
...
[xstream-scm] [jira] Created: (XSTR-395) PermGen Space ...
So I searched through the code of XStream and found StringConverter.
java. StringConverter is interning strings to unify them to reduce the
memory footprint. This is basically not a bad ideas but I have the feeling that String.intern()
...
Effective pagination using Hibernate This a...
The problem with this approach is that it is
memory intensive. On most 32-bit systems, there is a practical upper limit of around 2GB
heap, which will make it difficult to have more than three such queries running simultaneously [1].
...
Thoughts about Azul
I do know of customers who use a single multithreaded process with a very large
memory footprint to do big calculations on Azul – the time to results is accelerated by this approach since the entire result set is already in one place.
...