10
I have a fairly complex system in Scala, with multiple threads and simultaneous system calls. This system is having some problem, because busy memory grows over time.
The image below shows the memory occupation of the machine over a day. When it reaches the limit, the process falls and I put a watch-dog to lift it again.
I periodically run the command
jcmd <pid> GC.run
And it makes the memory not grow so fast, but still the problem persists.
I did an analysis with the jvisualvm, comparing the heap in 2 different moments, with 40 minutes of difference. The image below shows a comparison between the heap at time 1 and the heap at time 0. Note that there is a considerable increase in instances of some classes, such as ConcurrentHashMap$HashEntry
, SNode
, WeakReference
, char[]
and String
and various package classes scala.collection.concurrent
.
What might be causing my memory Leak?
Edit 1: Investigating by Jvisualvm, I noticed that the objects of the class Cnode and Inode are in Triedmap, which in turn are instantiated in the class sbt.Trapexit$App. See the hierarchy of objects in the figure:
It may be that there is a memory Leak because of the java Weak References in Snode. Some (s) part of the code may be causing this. http://www.scala-lang.org/api/2.10.2/index.html#scala.ref.Weakreference
– Tony
Buddy, take a look at this tutorial. After a scan in your code again. :)
– Fábio Zoz
I looked at the article, Fabio, but it doesn’t help much... I can not find in my code any point where I am storing objects that do not lose references, at least not that I have identified...
– Daniel Cukier