Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Plumbing memory leaks

Plumbing memory leaks

Nikita Salnikov-Tarnovski

October 27, 2013
Tweet

Transcript

  1. Promises No size calculation and explicit malloc Just call new

    No need to free Just forget and let GC handle it! Confined heap
  2. OOM: Java Heap Space! PermGen space! GC overhead limit exceeded!

    requested XX bytes for Chunk::new. Out of swap space?! unable to create new native thread! allocLargeObjectOrArray! nativeGetNewTLA
  3. Why OOM? Your code is too greedy!! Tries to use

    too much memory at once! Inefficient algorithm/data structure
  4. Quiz How much memory is needed to put 10M integers

    into a java.util.HashSet?! 40M! 100M! 300M! 600M 547M
  5. GC A subsystem of JVM, which periodically checks which objects

    in memory are still being used and which are not. Unused objects can be discarded and memory reclaimed and reused again.! Not a mind-reading magician
  6. Memory leak A situation where some objects are not used

    by application any more, but GC fails to recognize them as unused! The notion of “object is not used by application any more” is totally, absolutely, 100% application specific!! http://plumbr.eu/blog/what-is-a-memory-leak
  7. Results crashes, sometimes together with the application;! tons of flickering

    dashboards, graphics, buttons, bells and whistles, but no answer;! console full of cryptic text and java class names;! … or application adapted for snails and turtles, with response times increased 5-350 times.! http://plumbr.eu/blog/solving-outofmemoryerror-no-tools-will-help-you
  8. Memory Analyzer (MAT) From Eclipse! It really works! If you

    have experience! http://www.eclipse.org/mat/
  9. How it works Java agent with native part! Runs alongside

    your application in the same JVM! Monitors objects lifecycle! Makes decision based on per-class data
  10. Glooms Doesn’t work in synthetic test applications! Find leaks, not

    explosions! Doesn’t help with native memory problems
  11. Shines Gives you the answer, not just data! Before customers

    start to suffer! Small overhead compared to profilers! No upfront investment