Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appender OutOf Memory Error for MuleSoft Apps #121

Closed
KHALIFA-SH opened this issue Dec 16, 2023 Discussed in #120 · 2 comments
Closed

Appender OutOf Memory Error for MuleSoft Apps #121

KHALIFA-SH opened this issue Dec 16, 2023 Discussed in #120 · 2 comments

Comments

@KHALIFA-SH
Copy link

Discussed in #120

Originally posted by KHALIFA-SH December 16, 2023
I have Used the log4j2 appender in MuleSoft project and I'm getting an outOfMemory Error when sending logs to Loki.
Attached the stack trace...
When I upgrade the worker size to at least 0.2 V core I don't see this error. I just want to ask if there is something I can do to avoid this error with minimal worker size (.01 v core).

Thank you!

Error Stack

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  • Initializing app 'grafana-loki-test' +
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ERROR StatusConsoleListener Could not create plugin of type class pl.tkowalcz.tjahzi.log4j2.LokiAppender for element Loki: java.lang.OutOfMemoryError: Direct buffer memory
    java.lang.OutOfMemoryError: Direct buffer memory
    at java.nio.Bits.reserveMemory(Bits.java:695)
    at java.nio.DirectByteBuffer.(DirectByteBuffer.java:123)
    at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311)
    at pl.tkowalcz.tjahzi.TjahziInitializer.allocateJavaBuffer(TjahziInitializer.java:101)
    at pl.tkowalcz.tjahzi.TjahziInitializer.createLoggingSystem(TjahziInitializer.java:32)
    at pl.tkowalcz.tjahzi.log4j2.LokiAppenderBuilder.build(LokiAppenderBuilder.java:152)
    at pl.tkowalcz.tjahzi.log4j2.LokiAppenderBuilder.build(LokiAppenderBuilder.java:30)
    ....
    ERROR StatusConsoleListener Unable to invoke factory method in class pl.tkowalcz.tjahzi.log4j2.LokiAppender for element Loki: java.lang.IllegalStateException: No factory method found for class pl.tkowalcz.tjahzi.log4j2.LokiAppender
    java.lang.IllegalStateException: No factory method found for class pl.tkowalcz.tjahzi.log4j2.LokiAppender
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:260)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:136)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1138)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1063)
    ....
@kshkur
Copy link

kshkur commented Dec 27, 2023

Fixed with "bufferSizeMegabytes" allocation

@tkowalcz
Copy link
Owner

Hi. Sorry for a late answer. The JVM has a user-settable upper limit on the maximum amount of allocatable direct buffer memory. It can be controlled by -XX:MaxDirectMemorySize=<size> option to java invocation. The stack trace indicates that you hit that limit.

The solution is to set smaller buffer like @kshkur suggests or set useOffHeapBuffer to false in Tjahzi configuration so that the buffer will be allocated on java heap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants