You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dhaval Jaiswal <dh...@via.com> on 2018/12/22 12:35:23 UTC

insufficient memory for the Java Runtime Environment to continue

I am facing issue of crashing JAVA process and log files attached for the
same.

Server total RAM is 16 GB.

catalina.sh having following setting.
export JAVA_MEM_OPTS="-Xms1g -Xmx15g -XX:MaxPermSize=1536m"

Can some one help where could be the problem? Which threads are consuming
memory. How can i get rid out of this issue.

Re: insufficient memory for the Java Runtime Environment to continue

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

Leon,

On 12/22/18 08:19, Leon Rosenberg wrote:
> You should provide at least Java version. Out of the blue you
> should have at least 2Gb for the OS, so if your server is having 16
> Gb, your Xmx and MaxPermSize shouldn't be more then 14 G TOGETHER.
> Of course this only applies to versions of java below 1.8, because
> there is no permspace in modern jvms anymore (called metaspace
> now) and in this case this setting doesn't do anything. Still, you
> should reduce Xmx to 13 or less.

There's also non-heap ("native") memory, too, which isn't limited. If
I had server with 16GiB RAM I wouldn't think of getting anywhere near
a 14GiB heap.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlwecDgACgkQHPApP6U8
pFjyHQ//S8Xaaw+UDDgWjY/795v6XqF120opjR4bVHB6/NTqNXBXyP6dtkXF5EVW
ae4Q9CSlYjc9Cq2kQzmwyeLhpD8w7/81oz2dmMJYZJ5HUWzI+vHOF8LQ5cjFcOoZ
hubj8q8wPmMN7fvMdauPhkUBXTOjZhXVcsz6gd90NKor3V7apEnPYHKiG+0JjMH1
Gf0yf2Azkx1rnYaK5h0f8hZ6eu0qGEgDfQySmYmp7T0A44Z6V0dD/i9Oj1Fir13o
bxTGEVZ43rfqUHLFCDNgmKcdQrLpplI2H/BsS2jolWQNSG5hZpMx00O3Gx6GMYlS
fUzt7wavU8zrUbDUPWDdSJAQ0nPTICm4JeTWJVMSC7mvMWRzMmlbbYnsqeDbnXP7
i1MAvsiu5kfmxnFuu57ha70iRVt4UsrINlkozAZXz8i9NCi4zdhQUDoX9jf+9EcN
Hq1TxP8C0LYUDWJ1JM/qbTmjV/3RSwQfpaPubb6UtafOkC4I0kWviWp26fTmEfMF
jnG+76cRQQ8H/iifVJx16p+mmu5yZJrgDv16vrWP3+u0rl9TJvXmPznWBCbtqhHa
iQfjzaYB2LoCWeEZnjd9M6bwa/ynf2AKXkixiABuNy5jcEIlKgEeODuDmvktJkbe
uOCO79mHRoPxVhL7aHvDPyTkQ9lzjEYbG3ELF02k7r7VG/GhZKM=
=IcKU
-----END PGP SIGNATURE-----

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


Re: insufficient memory for the Java Runtime Environment to continue

Posted by Dhaval Jaiswal <dh...@via.com>.
Java version 8




On Sat 22 Dec, 2018, 6:49 PM Leon Rosenberg <rosenberg.leon@gmail.com wrote:

> You should provide at least Java version.
> Out of the blue you should have at least 2Gb for the OS, so if your server
> is having 16 Gb, your Xmx and MaxPermSize shouldn't be more then 14 G
> TOGETHER. Of course this only applies to versions of java below 1.8,
> because there is no permspace in modern jvms anymore (called metaspace now)
> and in this case this setting doesn't do anything. Still, you should reduce
> Xmx to 13 or less.
> Leon
>
> On Sat, Dec 22, 2018 at 1:35 PM Dhaval Jaiswal <dh...@via.com>
> wrote:
>
> > I am facing issue of crashing JAVA process and log files attached for the
> > same.
> >
> > Server total RAM is 16 GB.
> >
> > catalina.sh having following setting.
> > export JAVA_MEM_OPTS="-Xms1g -Xmx15g -XX:MaxPermSize=1536m"
> >
> > Can some one help where could be the problem? Which threads are consuming
> > memory. How can i get rid out of this issue.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
>

Re: insufficient memory for the Java Runtime Environment to continue

Posted by Leon Rosenberg <ro...@gmail.com>.
You should provide at least Java version.
Out of the blue you should have at least 2Gb for the OS, so if your server
is having 16 Gb, your Xmx and MaxPermSize shouldn't be more then 14 G
TOGETHER. Of course this only applies to versions of java below 1.8,
because there is no permspace in modern jvms anymore (called metaspace now)
and in this case this setting doesn't do anything. Still, you should reduce
Xmx to 13 or less.
Leon

On Sat, Dec 22, 2018 at 1:35 PM Dhaval Jaiswal <dh...@via.com>
wrote:

> I am facing issue of crashing JAVA process and log files attached for the
> same.
>
> Server total RAM is 16 GB.
>
> catalina.sh having following setting.
> export JAVA_MEM_OPTS="-Xms1g -Xmx15g -XX:MaxPermSize=1536m"
>
> Can some one help where could be the problem? Which threads are consuming
> memory. How can i get rid out of this issue.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

Re: insufficient memory for the Java Runtime Environment to continue

Posted by Olaf Kock <to...@olafkock.de>.
On 22.12.18 22:58, Dhaval Jaiswal wrote:
> Application built in such a way that it consum memory and hence, it's
> exhaust all memory and results in crashing Java. Probably GC is not running
> when it reaches to its threshold. Is there a way I can call GC explicitly
> without affecting running application. I believe  need to identify the
> memory consumption as well.

I'd recommend to run the whole system in a profiler, set the memory as
advised to the same -Xms and -Xmx values.

GC *always* runs before an OutOfMemory condition - however, if it's an
allocation issue, technically the JVM isn't out of memory with your
original settings, because it rightfully tries to allocate more from the
OS until it reaches -Xmx. In that case it'd be correct to just stop
working if the OS can't provide more memory.

If you legitimately use that much memory for operations, you might want
to throttle the rate of processing - but we can't tell you where your
code problems are without your code. The problem is clearly application
specific and not tomcat related, as Tomcat happily runs with a lot less
memory.

In the beginning of this (mail-)thread you asked, which thread is
consuming  the memory: We don't know, and as memory isn't allocated to a
thread, it doesn't matter.

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


Re: insufficient memory for the Java Runtime Environment to continue

Posted by John Dale <jc...@gmail.com>.
Yikes .. no matter how much memory you allocate, it'll eventually consume it?

I ran into this problem a few times and I reviewed the application
code looking for the cause through testing.

A memory profiler can work, but I've found them to be somewhat
unwieldy and difficult.  Dumps can also give a good clue to what is
happening .. one of the biggest offenders that I found was in a loop
was being created large strings that were stored in a static
collection or an instance level variable.

I would recommend testing your application and noting which services
seem to result in increased memory.  Then, code review those services,
first and fix memory leaks.  Then re-test, repeat.

If all services seem to result in rampant memory consumption you might
check code common to all services like database connection management
or some commonly used library.  This would be great since you can fix
the code on one place and it would apply to all services.

I've fixed this type of issue a lot .. being able to read the code and
find memory leaks without a profiler is .. a good skill to acquire.

Have a super day and best of luck!

John


On 12/22/18, Dhaval Jaiswal <dh...@via.com> wrote:
> Application built in such a way that it consum memory and hence, it's
> exhaust all memory and results in crashing Java. Probably GC is not running
> when it reaches to its threshold. Is there a way I can call GC explicitly
> without affecting running application. I believe  need to identify the
> memory consumption as well.
>
>
>
>
>
>
>
> On Sun 23 Dec, 2018, 2:23 AM Olaf Kock <tomcat@olafkock.de wrote:
>
>>
>> On 22.12.18 20:17, Dhaval Jaiswal wrote:
>> > System has allocated all mentioned RAM.
>> >
>> > I assume 13 would be fine.
>>
>> Adding to John's question, what I forgot earlier: Another rule of thumb
>> is to identify the *minimum* amount of memory that the application can
>> run with, then add a bit of headroom. Typically there's no need to go
>> with a humongous heap if garbage collection has a chance to free it all
>> up quickly. Memory in webappliations typically tends to be largely
>> short-lived, and (especially) the young generation GC is typically
>> extremely quick. You want it to rather run often (e.g. through an
>> imposed memory limit) than rarely (due to a too large heapspace).
>>
>> Olaf
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>


-- 
"Innovation is hard to schedule." -- Dan Fylstra

*This email and any attachments to it may be confidential and are intended
solely for the use of the individual(s) to whom it is addressed.  If you
are not the intended recipient of this email, you must neither take any
action based upon its contents, nor copy or show it to anyone.  Please
contact the sender if you believe you have received this email in error.*

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


Re: insufficient memory for the Java Runtime Environment to continue

Posted by Dhaval Jaiswal <dh...@via.com>.
Application built in such a way that it consum memory and hence, it's
exhaust all memory and results in crashing Java. Probably GC is not running
when it reaches to its threshold. Is there a way I can call GC explicitly
without affecting running application. I believe  need to identify the
memory consumption as well.







On Sun 23 Dec, 2018, 2:23 AM Olaf Kock <tomcat@olafkock.de wrote:

>
> On 22.12.18 20:17, Dhaval Jaiswal wrote:
> > System has allocated all mentioned RAM.
> >
> > I assume 13 would be fine.
>
> Adding to John's question, what I forgot earlier: Another rule of thumb
> is to identify the *minimum* amount of memory that the application can
> run with, then add a bit of headroom. Typically there's no need to go
> with a humongous heap if garbage collection has a chance to free it all
> up quickly. Memory in webappliations typically tends to be largely
> short-lived, and (especially) the young generation GC is typically
> extremely quick. You want it to rather run often (e.g. through an
> imposed memory limit) than rarely (due to a too large heapspace).
>
> Olaf
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: insufficient memory for the Java Runtime Environment to continue

Posted by Olaf Kock <to...@olafkock.de>.
On 22.12.18 20:17, Dhaval Jaiswal wrote:
> System has allocated all mentioned RAM.
>
> I assume 13 would be fine.

Adding to John's question, what I forgot earlier: Another rule of thumb
is to identify the *minimum* amount of memory that the application can
run with, then add a bit of headroom. Typically there's no need to go
with a humongous heap if garbage collection has a chance to free it all
up quickly. Memory in webappliations typically tends to be largely
short-lived, and (especially) the young generation GC is typically
extremely quick. You want it to rather run often (e.g. through an
imposed memory limit) than rarely (due to a too large heapspace).

Olaf



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


Re: insufficient memory for the Java Runtime Environment to continue

Posted by John Dale <jc...@gmail.com>.
Why are you requiring so much memory?



On 12/22/18, Dhaval Jaiswal <dh...@via.com> wrote:
> System has allocated all mentioned RAM.
>
> I assume 13 would be fine.
>
> On Sat 22 Dec, 2018, 11:44 PM John Dale <jcdwrrc@gmail.com wrote:
>
>> I agree with this tactic .. I do the same thing.
>>
>> Cheers.
>>
>> On 12/22/18, Olaf Kock <to...@olafkock.de> wrote:
>> >
>> > On 22.12.18 13:35, Dhaval Jaiswal wrote:
>> >> I am facing issue of crashing JAVA process and log files attached for
>> >> the same.
>> >>
>> >> Server total RAM is 16 GB.
>> >>
>> >> catalina.sh having following setting.
>> >> export JAVA_MEM_OPTS="-Xms1g -Xmx15g -XX:MaxPermSize=1536m"
>> >>
>> >> Can some one help where could be the problem? Which threads are
>> >> consuming memory. How can i get rid out of this issue.
>> >
>> > In addition to all the other great answers you already got: I've made
>> > it
>> > a principle to configure production systems with identical values for
>> > -Xms and -Xmx. In the end I'm intending to provide the max memory
>> > anyways, and if something goes wrong along the way (as it does for you
>> > in this situation) I prefer to know of the problems right when I start
>> > up the server - not Sunday night at 3am when it tries to allocate the
>> > missing (and allowed) chunk of memory from the OS before failing.
>> >
>> > Experimenting along this principle will help you to quickly figure out
>> > how much memory your system actually can provide (be aware of the
>> > required non-heap memory that Christopher mentioned, when forming your
>> > expectations.
>> >
>> > Cheers,
>> >
>> > Olaf
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> > For additional commands, e-mail: users-help@tomcat.apache.org
>> >
>> >
>>
>>
>> --
>> "Innovation is hard to schedule." -- Dan Fylstra
>>
>> *This email and any attachments to it may be confidential and are
>> intended
>> solely for the use of the individual(s) to whom it is addressed.  If you
>> are not the intended recipient of this email, you must neither take any
>> action based upon its contents, nor copy or show it to anyone.  Please
>> contact the sender if you believe you have received this email in error.*
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>


-- 
"Innovation is hard to schedule." -- Dan Fylstra

*This email and any attachments to it may be confidential and are intended
solely for the use of the individual(s) to whom it is addressed.  If you
are not the intended recipient of this email, you must neither take any
action based upon its contents, nor copy or show it to anyone.  Please
contact the sender if you believe you have received this email in error.*

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


Re: insufficient memory for the Java Runtime Environment to continue

Posted by Dhaval Jaiswal <dh...@via.com>.
System has allocated all mentioned RAM.

I assume 13 would be fine.

On Sat 22 Dec, 2018, 11:44 PM John Dale <jcdwrrc@gmail.com wrote:

> I agree with this tactic .. I do the same thing.
>
> Cheers.
>
> On 12/22/18, Olaf Kock <to...@olafkock.de> wrote:
> >
> > On 22.12.18 13:35, Dhaval Jaiswal wrote:
> >> I am facing issue of crashing JAVA process and log files attached for
> >> the same.
> >>
> >> Server total RAM is 16 GB.
> >>
> >> catalina.sh having following setting.
> >> export JAVA_MEM_OPTS="-Xms1g -Xmx15g -XX:MaxPermSize=1536m"
> >>
> >> Can some one help where could be the problem? Which threads are
> >> consuming memory. How can i get rid out of this issue.
> >
> > In addition to all the other great answers you already got: I've made it
> > a principle to configure production systems with identical values for
> > -Xms and -Xmx. In the end I'm intending to provide the max memory
> > anyways, and if something goes wrong along the way (as it does for you
> > in this situation) I prefer to know of the problems right when I start
> > up the server - not Sunday night at 3am when it tries to allocate the
> > missing (and allowed) chunk of memory from the OS before failing.
> >
> > Experimenting along this principle will help you to quickly figure out
> > how much memory your system actually can provide (be aware of the
> > required non-heap memory that Christopher mentioned, when forming your
> > expectations.
> >
> > Cheers,
> >
> > Olaf
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
>
> --
> "Innovation is hard to schedule." -- Dan Fylstra
>
> *This email and any attachments to it may be confidential and are intended
> solely for the use of the individual(s) to whom it is addressed.  If you
> are not the intended recipient of this email, you must neither take any
> action based upon its contents, nor copy or show it to anyone.  Please
> contact the sender if you believe you have received this email in error.*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: insufficient memory for the Java Runtime Environment to continue

Posted by John Dale <jc...@gmail.com>.
I agree with this tactic .. I do the same thing.

Cheers.

On 12/22/18, Olaf Kock <to...@olafkock.de> wrote:
>
> On 22.12.18 13:35, Dhaval Jaiswal wrote:
>> I am facing issue of crashing JAVA process and log files attached for
>> the same.
>>
>> Server total RAM is 16 GB.
>>
>> catalina.sh having following setting.
>> export JAVA_MEM_OPTS="-Xms1g -Xmx15g -XX:MaxPermSize=1536m"
>>
>> Can some one help where could be the problem? Which threads are
>> consuming memory. How can i get rid out of this issue.
>
> In addition to all the other great answers you already got: I've made it
> a principle to configure production systems with identical values for
> -Xms and -Xmx. In the end I'm intending to provide the max memory
> anyways, and if something goes wrong along the way (as it does for you
> in this situation) I prefer to know of the problems right when I start
> up the server - not Sunday night at 3am when it tries to allocate the
> missing (and allowed) chunk of memory from the OS before failing.
>
> Experimenting along this principle will help you to quickly figure out
> how much memory your system actually can provide (be aware of the
> required non-heap memory that Christopher mentioned, when forming your
> expectations.
>
> Cheers,
>
> Olaf
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
"Innovation is hard to schedule." -- Dan Fylstra

*This email and any attachments to it may be confidential and are intended
solely for the use of the individual(s) to whom it is addressed.  If you
are not the intended recipient of this email, you must neither take any
action based upon its contents, nor copy or show it to anyone.  Please
contact the sender if you believe you have received this email in error.*

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


Re: insufficient memory for the Java Runtime Environment to continue

Posted by Olaf Kock <to...@olafkock.de>.
On 22.12.18 13:35, Dhaval Jaiswal wrote:
> I am facing issue of crashing JAVA process and log files attached for
> the same. 
>
> Server total RAM is 16 GB.
>
> catalina.sh having following setting. 
> export JAVA_MEM_OPTS="-Xms1g -Xmx15g -XX:MaxPermSize=1536m"
>
> Can some one help where could be the problem? Which threads are
> consuming memory. How can i get rid out of this issue.

In addition to all the other great answers you already got: I've made it
a principle to configure production systems with identical values for
-Xms and -Xmx. In the end I'm intending to provide the max memory
anyways, and if something goes wrong along the way (as it does for you
in this situation) I prefer to know of the problems right when I start
up the server - not Sunday night at 3am when it tries to allocate the
missing (and allowed) chunk of memory from the OS before failing.

Experimenting along this principle will help you to quickly figure out
how much memory your system actually can provide (be aware of the
required non-heap memory that Christopher mentioned, when forming your
expectations.

Cheers,

Olaf



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


Re: insufficient memory for the Java Runtime Environment to continue

Posted by Johan Compagner <jc...@servoy.com>.
If you use large heaps you should use G1 garbage collector
And if you use that then I would set the min and Max to the same values

*-server -Xms13G -Xmx13G **-XX:+UseG1GC*


*To fully initialize the memory at once (g1 will figure it into compartments)*


Op za 22 dec. 2018 13:35 schreef Dhaval Jaiswal <dhaval.jaiswal@via.com:

> I am facing issue of crashing JAVA process and log files attached for the
> same.
>
> Server total RAM is 16 GB.
>
> catalina.sh having following setting.
> export JAVA_MEM_OPTS="-Xms1g -Xmx15g -XX:MaxPermSize=1536m"
>
> Can some one help where could be the problem? Which threads are consuming
> memory. How can i get rid out of this issue.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org