parmindersk@[EMAIL PROTECTED]
wrote:
> I did that, but that doesn't 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 have 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 will not 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've 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 don't
cause leaked resources).
Cheers
Dave
> On May 30, 4:53 pm, Joshua Cranmer <Pidgeo...@[EMAIL PROTECTED]
> wrote:
>
>>parminde...@[EMAIL PROTECTED]
wrote:
>>
>>>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 will not 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,?}/
>
>
>


|