Memory leak with Scala and processes (memory leak)

10

I have a reasonably complex system in Scala, with multiple threads and concurrent system calls. This system has a problem, because busy memory grows over time.

From the image below, you can see the memory occupation of the machine over the course of a day. When it reaches the limit, the process falls and I put on a watch-dog to raise it again.

Iperiodicallyrunthecommand

jcmd<pid>GC.run

Andthisdoesnotmakethememorygrowsofast,buttheproblemstillpersists.

Ididananalysiswithjvisualvm,comparingtheheapin2differentmoments,40minutesapart.Theimagebelowshowsacomparisonbetweentheheapattime1andtheheapattime0.Notethatthereisaconsiderableincreaseofinstancesofsomeclasses,suchasConcurrentHashMap$HashEntry,SNode,WeakReference,char[]andStringandvariousclassesofthescala.collection.concurrentpackage.

Whatmightbecausingmymemoryleak?

Edit 1 : Investigating through JVisualVM, I noticed that the objects of class CNode and INode are in TriedMap, which in turn are instantiated in class sbt.TrapExit $ App. See the hierarchy of objects in the figure:

Post in English

    
asked by anonymous 14.09.2014 / 17:31

1 answer

4

These objects are all part of scala.collection.concurrent.TrieMap . As you indicated, SBT is the one who uses this, my suggestion is that you stop using SBT to start your application.

Use a SBT plugin such as sbt-one-jar, sbt-assembly, or sbt-proguard that generates a JAR containing all dependencies, so you can start your application with java -jar sua-aplicacao.jar .

    
18.09.2014 / 21:25