How to cap memory required by VM
My application runs into this at times and causes the JVM(1.4.07 on Linux) to crash:
Exception in thread "CompilerThread0" java.lang.OutOfMemoryError: requested 1611132 bytes for Chunk::new. Out of swap space?
From looking at the forums, it looks like this occurs when the VM is unable to allocate enough memory at runtime for its native threads. I have the native stack size set to 512k using the Xss option. One of the workarounds suggested in the bug db http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4916142 suggests using the -XX:UseDefaultStackSize option in addition to Xss - but i am not sure what the XX:UseDefaultStackSize does when -Xss is also specified.
Is there a way to ensure that the total memory required by the JVM is < a given number at VM startup time?
This i am hoping would preclude the VM crashes. Though the Java heap caps the object allocation, the stack size gets allocated as and when the threads need them.
thanks
[1002 byte] By [
rhea] at [2007-10-3 2:14:56]

I'm not familar with that specific error message, but it sounds (to me) like it's a case of insufficient heap size. Have you tried a larger value for -Xmx? The default is 64MB, try -Xmx128m
As far as I know there is no way to limit the total size of the process.
You can control it by either:
1. Control the number of threads you create.
2. Limit the heap size so you will have more memory for native heap.
3. Prevent hotspot optimizations (requires native heap)
Are you loading a lot of classes / loading the same class through class loader? If so limiting the perm size can help.
haimya at 2007-7-14 19:13:46 >

> As far as I know there is no way to limit the total
> size of the process.
> You can control it by either:
> 1. Control the number of threads you create.
> 2. Limit the heap size so you will have more memory
> for native heap.
> 3. Prevent hotspot optimizations (requires native
> heap)
>
> Are you loading a lot of classes / loading the same
> class through class loader? If so limiting the perm
> size can help.
Thanks for the suggestions. I have been trying to control the number of threads created but have not figured out the magic number yet.
Not sure what kind of negative impact turning off HotSpot would have since our application is fairly repetitive in terms of its execution path.
I will check the perm size and see what can be done. Since all the classes are being loaded by the appserver(JBoss), not sure how much control i have over this.
-Thanks
rhea at 2007-7-14 19:13:46 >
