Can logging a huge message (around 90 MB) cause OutOfMemory Error? (Max heap size : 2048M)
<p>Actually, I receive a message through RabbitMQ which is large.
While consuming this message, we log it.</p>

<pre><code>logger.info("payload: {}", payload);
</code></pre>

<p>I see the following exception in logs at the logger statement line.</p>

<blockquote>
  <p>Caused by: java.lang.OutOfMemoryError: Java heap space
      at java.util.Arrays.copyOf(Arrays.java:3332)
      at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:137)
      at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:121)
      at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:421)
      at java.lang.StringBuffer.append(StringBuffer.java:272)
      at org.apache.log4j.helpers.PatternParser$LiteralPatternConverter.format(PatternParser.java:419)
      at org.apache.log4j.PatternLayout.format(PatternLayout.java:506)
      at org.graylog2.GelfMessageFactory.makeMessage(GelfMessageFactory.java:37)
      at org.graylog2.log.GelfAppender.append(GelfAppender.java:220)
      at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
      at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
      at org.apache.log4j.Category.callAppenders(Category.java:206)
      at org.apache.log4j.Category.forcedLog(Category.java:391)
      at org.apache.log4j.Category.log(Category.java:856)
      at org.slf4j.impl.Log4jLoggerAdapter.info(Log4jLoggerAdapter.java:324)</p>
</blockquote>

<p>After getting rid of the logger statement, the message was processed successfully.</p>

<p>So, can I be sure that the logger was causing the <code>OutOfMemoryError</code>?
Or it is something else that is causing the <code>OutOfMemoryError</code>?</p>

<p>Heap size is : 2048M</p>