You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Krister Nilsson <kr...@pensionsmyndigheten.se> on 2021/09/21 10:49:13 UTC

java.lang.OutOfMemoryError: Metaspace

Hello!

Not entirely sure this is the right forum, but I hope so. If not pls direct me to the correct place.

We have a test plan looking as below, where I can provide you with more details if necessary. It contains two "sub-tests" called "Extern" and "Admin". They are basically the same, only the test data being fed is slightly different, and they have different end points and need different tokens.

The problem now is that the sub-test called "Extern" crashes after (let's say) an hour while "Admin" does not crash (at least not within the time scope for the test).
Reason is java.lang.OutOfMemoryError: Metaspace
and
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Starter Thread Group 1-1"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "StandardJMeterEngine"

I do have a hprof-file which gunzipped is roughly 39 MB, which I found a little big sending out in a forum like this, but I can of course provide you with it.

Anyone who can help us with what is wrong or at least more details about the actual cause?

BR
/Krister


[cid:image001.png@01D7AEE7.13C9A720]

SV: java.lang.OutOfMemoryError: Metaspace

Posted by Krister Nilsson <kr...@pensionsmyndigheten.se>.
Thanks Felix!

We will try your suggestions. The sampler in Extern (and Admin) is HTTP Request.

BR
/Krister

Från: Felix Schumacher <fe...@internetallee.de>
Skickat: den 21 september 2021 13:46
Till: user@jmeter.apache.org
Ämne: Re: java.lang.OutOfMemoryError: Metaspace


Hi Krister,
Am 21.09.21 um 12:49 schrieb Krister Nilsson:
Hello!

Not entirely sure this is the right forum, but I hope so. If not pls direct me to the correct place.

We have a test plan looking as below, where I can provide you with more details if necessary. It contains two “sub-tests” called “Extern” and “Admin”. They are basically the same, only the test data being fed is slightly different, and they have different end points and need different tokens.

The problem now is that the sub-test called “Extern” crashes after (let’s say) an hour while “Admin” does not crash (at least not within the time scope for the test).
Reason is java.lang.OutOfMemoryError: Metaspace
and
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Starter Thread Group 1-1"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "StandardJMeterEngine"

I do have a hprof-file which gunzipped is roughly 39 MB, which I found a little big sending out in a forum like this, but I can of course provide you with it.

Anyone who can help us with what is wrong or at least more details about the actual cause?

If needed, you could send me the hprof file privately, but maybe we can find the issue without it.

The OOM happens inside Metaspace, which is where class information is placed. One thing that comes to my mind related classes, is that you often find ${...} expressions inside JSR223 scripts together with caching (which is the default for newer JMeter versions). So check, those first. (what type is the sampler inside extern?)

Another thing would be more information about the exception, is there more detail available in jmeter.log?

As you have a lot of time, before the test crashes, you could use jmap to show information about the classes and their instances inside the JVM. (for example "jmap -histo $PID_OF_JMETER", or dump the complete memory with "jmap -dump:live,file=heap.hprof $PID_OF_JMETER" (might get big) or "jstat -gc $PID_OF_JMETER 2000".)

It could also be, that you have a big test, that requires more memory and you could adapt the env variables JVM_ARGS and HEAP (especially HEAP, as it sets the size for the Metaspace).

Felix

BR
/Krister


[cid:image001.png@01D7AF8E.9F584CE0]

Re: java.lang.OutOfMemoryError: Metaspace

Posted by Felix Schumacher <fe...@internetallee.de>.
Hi Krister,

Am 21.09.21 um 12:49 schrieb Krister Nilsson:
> Skärmklipp
>
> Hello!
>
>  
>
> Not entirely sure this is the right forum, but I hope so. If not pls
> direct me to the correct place.
>
>  
>
> We have a test plan looking as below, where I can provide you with
> more details if necessary. It contains two “sub-tests” called “Extern”
> and “Admin”. They are basically the same, only the test data being fed
> is slightly different, and they have different end points and need
> different tokens.
>
>  
>
> The problem now is that the sub-test called “Extern” crashes after
> (let’s say) an hour while “Admin” does not crash (at least not within
> the time scope for the test).
>
> Reason is /java.lang.OutOfMemoryError: Metaspace/
>
> and
>
> Exception: java.lang.OutOfMemoryError thrown from the
> UncaughtExceptionHandler in thread "Starter Thread Group 1-1"
>
>  
>
> Exception: java.lang.OutOfMemoryError thrown from the
> UncaughtExceptionHandler in thread "StandardJMeterEngine"
>
>  
>
> I do have a hprof-file which gunzipped is roughly 39 MB, which I found
> a little big sending out in a forum like this, but I can of course
> provide you with it.
>
>  
>
> Anyone who can help us with what is wrong or at least more details
> about the actual cause?
>
If needed, you could send me the hprof file privately, but maybe we can
find the issue without it.

The OOM happens inside Metaspace, which is where class information is
placed. One thing that comes to my mind related classes, is that you
often find ${...} expressions inside JSR223 scripts together with
caching (which is the default for newer JMeter versions). So check,
those first. (what type is the sampler inside extern?)

Another thing would be more information about the exception, is there
more detail available in jmeter.log?

As you have a lot of time, before the test crashes, you could use jmap
to show information about the classes and their instances inside the
JVM. (for example "jmap -histo $PID_OF_JMETER", or dump the complete
memory with "jmap -dump:live,file=heap.hprof $PID_OF_JMETER" (might get
big) or "jstat -gc $PID_OF_JMETER 2000".)

It could also be, that you have a big test, that requires more memory
and you could adapt the env variables JVM_ARGS and HEAP (especially
HEAP, as it sets the size for the Metaspace).

Felix

>  
>
> BR
>
> /Krister
>
>  
>
>  
>

SV: java.lang.OutOfMemoryError: Metaspace

Posted by Krister Nilsson <kr...@pensionsmyndigheten.se>.
Thanks Dmitri!

Appreciate your response. These actions we have already taken though. (We actually lowered the heap to trigger the fault faster.)

Cheers!
/Krister

Från: Dmitri T <gl...@live.com>
Skickat: den 21 september 2021 15:29
Till: JMeter Users List <us...@jmeter.apache.org>
Kopia: Simon Schelin <si...@pensionsmyndigheten.se>
Ämne: Re: java.lang.OutOfMemoryError: Metaspace

java.lang.OutOfMemoryError: Metaspace <https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html> indicates that the amount of space required to store the class metadata is exceeded.

In JMeter 5.4.1 the default setting is 256 megabytes, however if your test relies on Groovy scripting or 3rd-party libraries which generate/load classes on the fly it might be not sufficient.

So you can try increasing it twice and see whether it resolves your issue.

The relevant line of jmeter.bat startup script is #151<https://github.com/apache/jmeter/blob/rel/v5.4.1/bin/jmeter.bat#L151>, it looks like:

set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m

I would also recommend removing all the listeners from your test plan, they don't add any value and just consume valuable resources<https://www.blazemeter.com/blog/greedy-listeners-memory-leeches-performance-testing>.

________________________________
From: Krister Nilsson <kr...@pensionsmyndigheten.se>>
Sent: Tuesday, September 21, 2021 1:49 PM
To: JMeter Users List <us...@jmeter.apache.org>>
Cc: Simon Schelin <si...@pensionsmyndigheten.se>>
Subject: java.lang.OutOfMemoryError: Metaspace


Hello!



Not entirely sure this is the right forum, but I hope so. If not pls direct me to the correct place.



We have a test plan looking as below, where I can provide you with more details if necessary. It contains two “sub-tests” called “Extern” and “Admin”. They are basically the same, only the test data being fed is slightly different, and they have different end points and need different tokens.



The problem now is that the sub-test called “Extern” crashes after (let’s say) an hour while “Admin” does not crash (at least not within the time scope for the test).

Reason is java.lang.OutOfMemoryError: Metaspace

and

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Starter Thread Group 1-1"



Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "StandardJMeterEngine"



I do have a hprof-file which gunzipped is roughly 39 MB, which I found a little big sending out in a forum like this, but I can of course provide you with it.



Anyone who can help us with what is wrong or at least more details about the actual cause?



BR

/Krister





[cid:image001.png@01D7AF8D.86D1E0B0]

Re: java.lang.OutOfMemoryError: Metaspace

Posted by Dmitri T <gl...@live.com>.
java.lang.OutOfMemoryError: Metaspace <https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html> indicates that the amount of space required to store the class metadata is exceeded.

In JMeter 5.4.1 the default setting is 256 megabytes, however if your test relies on Groovy scripting or 3rd-party libraries which generate/load classes on the fly it might be not sufficient.

So you can try increasing it twice and see whether it resolves your issue.

The relevant line of jmeter.bat startup script is #151<https://github.com/apache/jmeter/blob/rel/v5.4.1/bin/jmeter.bat#L151>, it looks like:

set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m

I would also recommend removing all the listeners from your test plan, they don't add any value and just consume valuable resources<https://www.blazemeter.com/blog/greedy-listeners-memory-leeches-performance-testing>.

________________________________
From: Krister Nilsson <kr...@pensionsmyndigheten.se>
Sent: Tuesday, September 21, 2021 1:49 PM
To: JMeter Users List <us...@jmeter.apache.org>
Cc: Simon Schelin <si...@pensionsmyndigheten.se>
Subject: java.lang.OutOfMemoryError: Metaspace


Hello!



Not entirely sure this is the right forum, but I hope so. If not pls direct me to the correct place.



We have a test plan looking as below, where I can provide you with more details if necessary. It contains two “sub-tests” called “Extern” and “Admin”. They are basically the same, only the test data being fed is slightly different, and they have different end points and need different tokens.



The problem now is that the sub-test called “Extern” crashes after (let’s say) an hour while “Admin” does not crash (at least not within the time scope for the test).

Reason is java.lang.OutOfMemoryError: Metaspace

and

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Starter Thread Group 1-1"



Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "StandardJMeterEngine"



I do have a hprof-file which gunzipped is roughly 39 MB, which I found a little big sending out in a forum like this, but I can of course provide you with it.



Anyone who can help us with what is wrong or at least more details about the actual cause?



BR

/Krister





[cid:image001.png@01D7AEE7.13C9A720]