OutOfDirectMemoryError

Hi,

Appreicate if I can get some help on this one. My test is running into this issue.

01:42:13.272 [ERROR] i.g.h.c.i.HttpAppHandler - Fatal error io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 16777216 byte(s) of direct memory (used: 1056964615, max: 1073741824)

I looked at the history of this user group that it mentioned I should set -XX:MaxDirectMemorySize, I tried a few things but I cannot find where should I set this argument.

I am using maven with command line:

mvn gatling:test -Dgatling.simulationClass=myCom.ClientWorkflowSimulation

Hi,

have you tried this https://stackoverflow.com/questions/12498738/maven-out-of-memory-build-failure?

export MAVEN_OPTS="-XmsYourValueg -XmxYourValueg -XX:MaxDirectMemorySize=YourValuem"

I am using jenkins to start the test, I set -XX:MaxDirectMemorySize=2g under jenkins maven but it doesn’t seem to work

Any other solutions?

I tried on jenkins execute shell with

export MAVEN_OPTS="-Xmx4096M -XX:MaxDirectMemorySize=2g"
mvn gatling:test -Dgatling.simulationClass=ClientWorkflowSimulation

but i am still getting the same error as it were not taking in my maven setting

01:24:01.149 [ERROR] i.g.h.c.i.HttpAppHandler - Fatal error io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 16777216 byte(s) of direct memory (used: 1056964615, max: 1073741824) at io.netty.util.internal.PlatformDependent.incrementMemoryCounter(PlatformDependent.java:775) at io.netty.util.internal.PlatformDependent.allocateDirectNoCleaner(PlatformDependent.java:730) at io.netty.buffer.PoolArena$DirectArena.allocateDirect(PoolArena.java:645) at io.netty.buffer.PoolArena$DirectArena.newChunk(PoolArena.java:621) at io.netty.buffer.PoolArena.allocateNormal(PoolArena.java:204) at io.netty.buffer.PoolArena.tcacheAllocateSmall(PoolArena.java:174) at io.netty.buffer.PoolArena.allocate(PoolArena.java:136) at io.netty.buffer.PoolArena.allocate(PoolArena.java:128) at io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:378) at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:187) at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:178) at io.netty.handler.ssl.SslHandler.allocate(SslHandler.java:2210) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1382) at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1282) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1329) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480) at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748)

Try some googling here:
https://github.com/netty/netty/issues/7699

https://github.com/gatling/gatling/issues/3358

Hi

Thanks for helping out here unfortunately it still have the problem. I looked at the processes when my gatling test runs, I saw two java processes, the 1st one is started by me and the 2nd one I believed is started by gatling.

In the 2nd java process, there is a -Xmx1G config, I am suspecting this is the culprit that caused my OutOfDirectMemory error, how do I change this process setting? It is invoked by gatling i think

process 1:

root 1442480 1442437 0 01:08 pts/0 00:00:11 /bin/java -Xmx4096M -classpath /opt/maven/boot/plexus-classworlds-2.6.0.jar -Dclassworlds.conf=/opt/maven/bin/m2.conf -Dmaven.home=/opt/maven -Dlibrary.jansi.path=/opt/maven/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/var/lib/jenkins/workspace/QA_Performance_Test org.codehaus.plexus.classworlds.launcher.Launcher gatling:test -Dgatling.simulationClass=ClientWorkflowSimulation

process 2:
root 1442572 1442480 16 01:08 pts/0 00:05:20 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el8_4.x86_64/jre/bin/java -server -Xmx1G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:+HeapDumpOnOutOfMemoryError -XX:MaxInlineLevel=20 -XX:MaxTrivialSize=12 -XX:-UseBiasedLocking -Djdk.net.URLClassPath.disableClassPathURLCheck=true -Dgatling.simulationClass=ClientWorkflowSimulation -Dlibrary.jansi.path=/opt/maven/lib/jansi-native -jar /tmp/gatlingbooter7006757122097394169.jar io.gatling.app.Gatling /tmp/gatling-maven-plugin-1976583146813467598.args

Have you checked the documentation of the gatling-maven-plugin? In particular the configuration? https://gatling.io/docs/gatling/reference/current/extensions/maven_plugin/#configuration

Thanks Stéphane for pointing me to the right direction, really appreciate it.