altoo-ag/akka-kryo-serialization

java.lang.OutOfMemoryError: Java heap space

alexsp01 opened this issue · 2 comments

Hi All,
am load testing play feramwork and having this issue with the kryo serializarion, when just I created 100 virtual users:

Uncaught error from thread [application-akka.actor.default-dispatcher-3]: Java heap space, shutting down ActorSystem[application]
java.lang.OutOfMemoryError: Java heap space
at com.romix.akka.serialization.kryo.LZ4KryoCompressor.fromBinary(KryoSerializer.scala:93)
at com.romix.akka.serialization.kryo.KryoTransformer.$anonfun$fromPipeLine$2(KryoSerializer.scala:56)
at com.romix.akka.serialization.kryo.KryoTransformer$$Lambda$366/1058921154.apply(Unknown Source)
at scala.Function1.$anonfun$andThen$1(Function1.scala:52)
at scala.Function1$$Lambda$364/1931008760.apply(Unknown Source)
at com.romix.akka.serialization.kryo.KryoTransformer.fromBinary(KryoSerializer.scala:63)
at com.romix.akka.serialization.kryo.KryoSerializer.fromBinary(KryoSerializer.scala:351)
at akka.serialization.Serialization.$anonfun$deserialize$3(Serialization.scala:212)
at akka.serialization.Serialization$$Lambda$1250/438354696.apply(Unknown Source)
at scala.util.Try$.apply(Try.scala:209)
at akka.serialization.Serialization.deserialize(Serialization.scala:212)
at play.api.cache.redis.connector.AkkaDecoder.binaryToAnyRef(AkkaSerializer.scala:124)
at play.api.cache.redis.connector.AkkaDecoder.$anonfun$stringToAnyRef$2(AkkaSerializer.scala:128)
at play.api.cache.redis.connector.AkkaDecoder$$Lambda$1249/52226024.apply(Unknown Source)
at scala.Function1.$anonfun$andThen$1(Function1.scala:52)
at scala.Function1$$Lambda$364/1931008760.apply(Unknown Source)
at play.api.cache.redis.connector.AkkaDecoder.stringToAnyRef(AkkaSerializer.scala:128)
at play.api.cache.redis.connector.AkkaDecoder.untypedDecode(AkkaSerializer.scala:115)
at play.api.cache.redis.connector.AkkaDecoder.decode(AkkaSerializer.scala:99)
at play.api.cache.redis.connector.AkkaSerializerImpl.$anonfun$decode$1(AkkaSerializer.scala:165)
at play.api.cache.redis.connector.AkkaSerializerImpl$$Lambda$1247/714541774.apply(Unknown Source)
at scala.util.Try$.apply(Try.scala:209)
at play.api.cache.redis.connector.AkkaSerializerImpl.decode(AkkaSerializer.scala:165)
at play.api.cache.redis.connector.RedisConnectorImpl.play$api$cache$redis$connector$RedisConnectorImpl$$decode(RedisConnectorImpl.scala:52)
at play.api.cache.redis.connector.RedisConnectorImpl$$anonfun$get$1.applyOrElse(RedisConnectorImpl.scala:31)
at play.api.cache.redis.connector.RedisConnectorImpl$$anonfun$get$1.applyOrElse(RedisConnectorImpl.scala:28)
at scala.PartialFunction$OrElse.apply(PartialFunction.scala:168)
at scala.util.Success.$anonfun$map$1(Try.scala:251)
at scala.util.Success.map(Try.scala:209)
at scala.concurrent.Future.$anonfun$map$1(Future.scala:289)
at scala.concurrent.Future$$Lambda$1088/37142680.apply(Unknown Source)
at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)

With java serialization it handles more than 300 users.
Here is kryo init:

def customize(kryo:Kryo):Unit = {
    kryo.register(classOf[Array[String]])
    kryo.register(classOf[Array[Int]])
    kryo.register(classOf[Array[Long]])
    kryo.register(classOf[scala.collection.mutable.HashMap[String, Int]])
    kryo.register(classOf[Boolean])
    kryo.register(classOf[Date])
    kryo.register(classOf[Int])
    kryo.register(classOf[com.mohiva.play.silhouette.impl.authenticators.BearerTokenAuthenticator])
    kryo.register(classOf[String])
    kryo.register(classOf[scala.concurrent.duration.FiniteDuration])
    kryo.register(classOf[java.util.concurrent.TimeUnit])
    kryo.register(classOf[com.mohiva.play.silhouette.api.LoginInfo])

    kryo.register(classOf[scala.Some[AnyRef]])
    kryo.register(classOf[scala.Option[AnyRef]])

    kryo.register(classOf[scala.Tuple4[AnyRef, AnyRef, AnyRef, AnyRef]])

    kryo.register(classOf[DateTime], new JodaDateTimeSerializer)
    kryo.setReferences(false)
  }

idstrategy = "explicit"

Any ideas what could it be? Looks like memory leak somewhere.

thanks in advance.

luben commented

You can try disabling the LZ4 compression. Looks the OOM comes from there - not sure why.

@luben, thanks, that helped.
I have put post-serialization-transformations = "off,off" and the issue gone.

cheers.