You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Philippe ROUXEL <PR...@pactenovation.fr> on 2012/03/05 11:30:58 UTC

Tomcat7 OutOFMemoryError

When I set JAVA_OPTS= -Xmx1024m -Xss75m
 
I got: 
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: unable to c
reate new native thread
        at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
        at java.util.concurrent.FutureTask.get(FutureTask.java:83)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
va:1128)
 
I using windowsXP and tomcat7.0.26. 
 
Regards,
Philippe

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: RE : Tomcat7 OutOFMemoryError

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Philippe,

On 3/5/12 8:14 AM, Philippe ROUXEL wrote:
> 75MB of stack is needed by hibenate to save the data aka a graph.

What!? Does Hibernate have some kind of method that needs to call itself
recursively 100,000 times?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9U+QoACgkQ9CaO5/Lv0PBohQCgkNWLGYeCYUpza6SCeHWB0MfU
r/YAniIl3sAUg/59qNoh8CJmkJKDhCn/
=2gvb
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: RE : Tomcat7 OutOFMemoryError

Posted by Rainer Jung <ra...@kippdata.de>.
On 06.03.2012 18:21, Pid * wrote:
> On 6 Mar 2012, at 08:16, "André Warnier"<aw...@ice-sa.com>  wrote:
>
>> Pid wrote:
>>> On 06/03/2012 07:12, Rainer Frey wrote:
>>>> On 05.03.2012, at 14:14, Philippe ROUXEL wrote:
>>>>
>>>>>>> When I set JAVA_OPTS= -Xmx1024m -Xss75m
>>>>>> That means: each thread get a stack of 75MB. One of the following applies:
>>>>>> * the operating system has a limit on thread stack size
>>>>>> * the per process memory limit is reached before all initial tomcat threads are started
>>>>>> * the system runs out of total memory before all initial tomcat threads are started
>>>>>>
>>>>>> 75MB thread stack size seems quite insane, the default is around 1-2MB. Perhaps you meant to set -Xms (which sets the initial Java heap size)?
>>>>> 75MB of stack is needed by hibenate to save the data aka a graph.
>>>> I haven't used hibernate personally, but I never heard anything like that. So please elaborate. Where did you get that information?
>>>> Also what do you mean with "graph"? The graph of associated objects that are updated by one hibernate call, or is your data actually graph data?
>>>> If so, how is that mapped? do you have any self-referential associations?
>>>> Is it really stack that you are talking about?
>>> I'm also interested in the answers to these questions.
>>
>> Ok, to get back to the OP's original question/assumption :
>>
>> Assuming that "-Xss75M" tells the JVM to allocate 75 MB of memory for the stack of each new thread created by the JVM, and noting that for a typical Tomcat instance, a minimum of about 10 threads seem to be created (with an additional one for each request being processed), this setting of "-Xss75M" would mean that a minimum of 750 MB is being allocated for the threads' stack.
>>
>> Assuming on the other hand that this is a 32-bit system and JVM (the OP didn't really say, but was mentioning Windows XP), where the maximum addressable memory for a process is 4 GB (of which 1 GB more or less are used by the OS itself); and considering the setting of -Xmx1024M for the Heap; and considering that the rest of the JVM and Tomcat may use some 1024 MB by themselves (for other things than the Heap and thread stacks);
>> Considering all this thus, it is not really so surprising that the OP would get an OOM error at some point.
>>
>> Noting on the other hand that the JVM stack should be mainly used to push and pop subroutine/function parameters as they are being called, and that a reasonable stack size seems to be around 512KB at most, this explains several comments here which seem to put in doubt the wisdom of allocation 75 MB for the stack of each Java thread.
>
> 75Mb is far too much for the thread stack size in a normal application.
>
> I am not certain that it is necessarily fully allocated, just to
> confuse matters further. I vaguely remember another discussion about
> this, but can't find it in the archives.

By the way some slightly related anecdote: I once had to diagnose a 
strange situation which at the end was explained by a user setting 
ThreadStackSize to 2M. Note that the docs say ThreadStackSize is in K 
(Kilo Bytes) and the code in fact does multiply the given value with 
1000 (or 1024). So if you set ThreadStackSize to 2M verbatim you end up 
configuring a stack size of 2GB :)

I forgot whether Xss also is in K or is in Bytes. Interpreting 
ThreadStack Size in K and multiplying up all other units given in the 
value IMHO is one of the most strange decisions done when designing JVM 
flags.

Regards,

Rainer


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: RE : Tomcat7 OutOFMemoryError

Posted by Pid * <pi...@pidster.com>.
On 6 Mar 2012, at 08:16, "André Warnier" <aw...@ice-sa.com> wrote:

> Pid wrote:
>> On 06/03/2012 07:12, Rainer Frey wrote:
>>> On 05.03.2012, at 14:14, Philippe ROUXEL wrote:
>>>
>>>>>> When I set JAVA_OPTS= -Xmx1024m -Xss75m
>>>>> That means: each thread get a stack of 75MB. One of the following applies:
>>>>> * the operating system has a limit on thread stack size
>>>>> * the per process memory limit is reached before all initial tomcat threads are started
>>>>> * the system runs out of total memory before all initial tomcat threads are started
>>>>>
>>>>> 75MB thread stack size seems quite insane, the default is around 1-2MB. Perhaps you meant to set -Xms (which sets the initial Java heap size)?
>>>> 75MB of stack is needed by hibenate to save the data aka a graph.
>>> I haven't used hibernate personally, but I never heard anything like that. So please elaborate. Where did you get that information?
>>> Also what do you mean with "graph"? The graph of associated objects that are updated by one hibernate call, or is your data actually graph data?
>>> If so, how is that mapped? do you have any self-referential associations?
>>> Is it really stack that you are talking about?
>> I'm also interested in the answers to these questions.
>
> Ok, to get back to the OP's original question/assumption :
>
> Assuming that "-Xss75M" tells the JVM to allocate 75 MB of memory for the stack of each new thread created by the JVM, and noting that for a typical Tomcat instance, a minimum of about 10 threads seem to be created (with an additional one for each request being processed), this setting of "-Xss75M" would mean that a minimum of 750 MB is being allocated for the threads' stack.
>
> Assuming on the other hand that this is a 32-bit system and JVM (the OP didn't really say, but was mentioning Windows XP), where the maximum addressable memory for a process is 4 GB (of which 1 GB more or less are used by the OS itself); and considering the setting of -Xmx1024M for the Heap; and considering that the rest of the JVM and Tomcat may use some 1024 MB by themselves (for other things than the Heap and thread stacks);
> Considering all this thus, it is not really so surprising that the OP would get an OOM error at some point.
>
> Noting on the other hand that the JVM stack should be mainly used to push and pop subroutine/function parameters as they are being called, and that a reasonable stack size seems to be around 512KB at most, this explains several comments here which seem to put in doubt the wisdom of allocation 75 MB for the stack of each Java thread.

75Mb is far too much for the thread stack size in a normal application.

I am not certain that it is necessarily fully allocated, just to
confuse matters further. I vaguely remember another discussion about
this, but can't find it in the archives.


p


> I am far from a specialist, but considering that Hibernate seems to be some kind of "generic" tool, it is a bit unlikely that using it would require to set the stack size to an amount that is at least 150 times the JVM default, no ?
>
> All this seems to point - as usual - to some application problem, with as Chris pointed out some runaway recursive function call or similar.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: RE : Tomcat7 OutOFMemoryError

Posted by André Warnier <aw...@ice-sa.com>.
Pid wrote:
> On 06/03/2012 07:12, Rainer Frey wrote:
>> On 05.03.2012, at 14:14, Philippe ROUXEL wrote:
>>
>>>>> When I set JAVA_OPTS= -Xmx1024m -Xss75m
>>>> That means: each thread get a stack of 75MB. One of the following applies:
>>>> * the operating system has a limit on thread stack size
>>>> * the per process memory limit is reached before all initial tomcat threads are started
>>>> * the system runs out of total memory before all initial tomcat threads are started
>>>>
>>>> 75MB thread stack size seems quite insane, the default is around 1-2MB. Perhaps you meant to set -Xms (which sets the initial Java heap size)?
>>> 75MB of stack is needed by hibenate to save the data aka a graph.
>> I haven't used hibernate personally, but I never heard anything like that. So please elaborate. Where did you get that information?
>> Also what do you mean with "graph"? The graph of associated objects that are updated by one hibernate call, or is your data actually graph data?
>> If so, how is that mapped? do you have any self-referential associations?
>> Is it really stack that you are talking about?
> 
> I'm also interested in the answers to these questions.
> 

Ok, to get back to the OP's original question/assumption :

Assuming that "-Xss75M" tells the JVM to allocate 75 MB of memory for the stack of each 
new thread created by the JVM, and noting that for a typical Tomcat instance, a minimum of 
about 10 threads seem to be created (with an additional one for each request being 
processed), this setting of "-Xss75M" would mean that a minimum of 750 MB is being 
allocated for the threads' stack.

Assuming on the other hand that this is a 32-bit system and JVM (the OP didn't really say, 
but was mentioning Windows XP), where the maximum addressable memory for a process is 4 GB 
(of which 1 GB more or less are used by the OS itself); and considering the setting of 
-Xmx1024M for the Heap; and considering that the rest of the JVM and Tomcat may use some 
1024 MB by themselves (for other things than the Heap and thread stacks);
Considering all this thus, it is not really so surprising that the OP would get an OOM 
error at some point.

Noting on the other hand that the JVM stack should be mainly used to push and pop 
subroutine/function parameters as they are being called, and that a reasonable stack size 
seems to be around 512KB at most, this explains several comments here which seem to put in 
doubt the wisdom of allocation 75 MB for the stack of each Java thread.

I am far from a specialist, but considering that Hibernate seems to be some kind of 
"generic" tool, it is a bit unlikely that using it would require to set the stack size to 
an amount that is at least 150 times the JVM default, no ?

All this seems to point - as usual - to some application problem, with as Chris pointed 
out some runaway recursive function call or similar.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: RE : Tomcat7 OutOFMemoryError

Posted by Pid <pi...@pidster.com>.
On 06/03/2012 07:12, Rainer Frey wrote:
> 
> On 05.03.2012, at 14:14, Philippe ROUXEL wrote:
> 
>>>> When I set JAVA_OPTS= -Xmx1024m -Xss75m
>>>
>>> That means: each thread get a stack of 75MB. One of the following applies:
>>> * the operating system has a limit on thread stack size
>>> * the per process memory limit is reached before all initial tomcat threads are started
>>> * the system runs out of total memory before all initial tomcat threads are started
>>>
>>> 75MB thread stack size seems quite insane, the default is around 1-2MB. Perhaps you meant to set -Xms (which sets the initial Java heap size)?
>> 75MB of stack is needed by hibenate to save the data aka a graph.
> 
> I haven't used hibernate personally, but I never heard anything like that. So please elaborate. Where did you get that information?
> Also what do you mean with "graph"? The graph of associated objects that are updated by one hibernate call, or is your data actually graph data?
> If so, how is that mapped? do you have any self-referential associations?
> Is it really stack that you are talking about?

I'm also interested in the answers to these questions.


p



-- 

[key:62590808]


Re: RE : Tomcat7 OutOFMemoryError

Posted by Rainer Frey <ra...@inxmail.de>.
On 05.03.2012, at 14:14, Philippe ROUXEL wrote:

>>> When I set JAVA_OPTS= -Xmx1024m -Xss75m
>> 
>> That means: each thread get a stack of 75MB. One of the following applies:
>> * the operating system has a limit on thread stack size
>> * the per process memory limit is reached before all initial tomcat threads are started
>> * the system runs out of total memory before all initial tomcat threads are started
>> 
>> 75MB thread stack size seems quite insane, the default is around 1-2MB. Perhaps you meant to set -Xms (which sets the initial Java heap size)?
> 75MB of stack is needed by hibenate to save the data aka a graph.

I haven't used hibernate personally, but I never heard anything like that. So please elaborate. Where did you get that information?
Also what do you mean with "graph"? The graph of associated objects that are updated by one hibernate call, or is your data actually graph data?
If so, how is that mapped? do you have any self-referential associations?
Is it really stack that you are talking about?

Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE : Tomcat7 OutOFMemoryError

Posted by Philippe ROUXEL <PR...@pactenovation.fr>.
75MB of stack is needed by hibenate to save the data aka a graph.
 
Philippe

________________________________

De: Rainer Frey [mailto:rainer.frey@inxmail.de]
Date: lun. 05/03/2012 13:19
À: Tomcat Users List
Objet : Re: Tomcat7 OutOFMemoryError



On 05.03.2012, at 11:30, Philippe ROUXEL wrote:

> When I set JAVA_OPTS= -Xmx1024m -Xss75m

That means: each thread get a stack of 75MB. One of the following applies:
* the operating system has a limit on thread stack size
* the per process memory limit is reached before all initial tomcat threads are started
* the system runs out of total memory before all initial tomcat threads are started

75MB thread stack size seems quite insane, the default is around 1-2MB. Perhaps you meant to set -Xms (which sets the initial Java heap size)?

Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





Re: Tomcat7 OutOFMemoryError

Posted by Rainer Frey <ra...@inxmail.de>.
On 05.03.2012, at 11:30, Philippe ROUXEL wrote:

> When I set JAVA_OPTS= -Xmx1024m -Xss75m

That means: each thread get a stack of 75MB. One of the following applies:
* the operating system has a limit on thread stack size
* the per process memory limit is reached before all initial tomcat threads are started
* the system runs out of total memory before all initial tomcat threads are started

75MB thread stack size seems quite insane, the default is around 1-2MB. Perhaps you meant to set -Xms (which sets the initial Java heap size)?

Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org