title: Objectmapper writeValueAsString throwing OOM Exception
body: <p>I'm repeatedly converting an object to a String using the Jackson writeValueAsString method, like a couple of thousand times repeatedly. The size of JSON would be something around 1KB. But after a while, my program exits and throws OOM Exception. Following is the stacktrace:</p>
  
  <pre><code>Exception in thread "main" java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
          at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
  Caused by: java.lang.OutOfMemoryError: Java heap space
          at com.fasterxml.jackson.core.util.TextBuffer.carr(TextBuffer.java:864)
          at com.fasterxml.jackson.core.util.TextBuffer.expand(TextBuffer.java:825)
          at com.fasterxml.jackson.core.util.TextBuffer.append(TextBuffer.java:590)
          at com.fasterxml.jackson.core.io.SegmentedStringWriter.write(SegmentedStringWriter.java:58)
          at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator._writeString2(WriterBasedJsonGenerator.java:1013)
          at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator._writeString(WriterBasedJsonGenerator.java:982)
          at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator.writeString(WriterBasedJsonGenerator.java:377)
          at com.fasterxml.jackson.databind.ser.std.StringSerializer.serialize(StringSerializer.java:41)
          at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:718)
          at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
          at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
          at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
          at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
          at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3893)
          at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3207)
          at com.ad2pro.neonmigration.neondatamigration.utils.NeonMetricsProducerUtil.produceImpressions(NeonMetricsProducerUtil.java:121)
          at com.ad2pro.neonmigration.neondatamigration.scheduler.NeonScheduler.gerMetrics(NeonScheduler.java:100)
          at com.ad2pro.neonmigration.neondatamigration.NeonDataMigrationApplication.main(NeonDataMigrationApplication.java:18)
          ... 8 more
  java.lang.OutOfMemoryError: Java heap space
          at javax.crypto.CipherSpi.bufferCrypt(CipherSpi.java:814)
          at javax.crypto.CipherSpi.engineUpdate(CipherSpi.java:555)
          at javax.crypto.Cipher.update(Cipher.java:2002)
          at sun.security.ssl.CipherBox.decrypt(CipherBox.java:544)
          at sun.security.ssl.EngineInputRecord.decrypt(EngineInputRecord.java:200)
          at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:974)
          at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
          at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
          at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
          at com.amazon.support.channels.TLSSocketChannel.read(Unknown Source)
          at com.amazon.jdbc.communications.InboundMessagesThread.run(Unknown Source)
  ~                                       
  </code></pre>
  
  <p>There is 1GB of free memory before my program starts. Is objectmapper holding onto a lot of memory that even 1GB is not sufficient to convert objects to String. Any help is appreciated.</p>