quickperf icon indicating copy to clipboard operation
quickperf copied to clipboard

Add @ExpectNoInflaterMemoryLeak

Open jeanbisutti opened this issue 3 years ago • 5 comments

java.util.zip.Inflater can cause non-heap memory leaks, as explained in this presentation. They can be detected during the application execution thanks to the Leakchecker project. This issue aims to provide an @ExpectNoInflaterMemoryLeak annotation in QuickPerf to detect this memory leak as soon as possible. The @ExpectNoInflaterMemoryLeak will be based on the Leakchecker project. This project has an Apache 2.0 license so that it is ok to detect inflater memory leak in the same way in QuickPerf project. Both in QuickPerf source code and QuickPerf documentation, we will take care of mentioning the Leakchecker project.

This issue is focussed on memory leaks that could come from Inflater. Later, we could detect other kinds of potential memory leaks, such as those that could be raised from ObjectInputStream.

jeanbisutti avatar Aug 03 '20 17:08 jeanbisutti

Tomcat has a lot of memory leak protections since version 7: https://cwiki.apache.org/confluence/display/TOMCAT/MemoryLeakProtection

Maybe we can create multiple memory leak detection based on those examples. This could be a very cool addition to what quickperf already does!

loicmathieu avatar Sep 03 '20 16:09 loicmathieu

Btw. There is also Leak Canary from Square for detecting memory leaks. It's originally developed for Android apps, but there is some support for applying it for JVM apps: https://square.github.io/leakcanary/recipes/#detecting-leaks-in-jvm-applications . Perhaps some parts could be reused in QuickPerf?

lhotari avatar Dec 19 '20 11:12 lhotari

I ignored that Leak Canary could work with a JVM app. It would be interesting to reuse the Leak Canary HeapAnalyzer in QuickPerf.

jeanbisutti avatar Dec 19 '20 17:12 jeanbisutti

Information coming from interesting Twitter conversations about Leak Canary:

  • https://twitter.com/Piwai/status/1340311708775145474?s=20
  • https://github.com/square/leakcanary/issues/1917

jeanbisutti avatar Dec 19 '20 17:12 jeanbisutti

JFR may reveal some heap memory leaks with the help of the Old Object Sample event: http://hirt.se/blog/?p=1055

QuickPerf can trigger JFR profiling and retrieve JFR events.

However, the Old Object Sample event was introduced in JDK 10. So, the heap leak detection would only work from this JDK version.

jeanbisutti avatar Dec 19 '20 17:12 jeanbisutti