Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tools for native memory leak analysis

I am suspecting a native memory leak in my java code. Are there any tools which do native memory profiling? Also, does any tool support native memory analysis of a running java process?

Thanks!!

Edit: I have already tried Memory Validator and Purify but it seems they support only 32-bit processes. Is there some tool similar to the above ones which can simply attach to a running windows process and give us native memory analysis for that particular process?

like image 248
cooltechnomax Avatar asked Jul 28 '11 17:07

cooltechnomax


People also ask

What are some of the best tools for diagnosing memory leaks?

To name a few: The CRT Debug Heap ( which is no longer used by default in Visual Studio 2015! UMDH (from the Debugging Tools for Windows) can diagnose memory leaks by using built-in Windows support for capturing allocation stack traces.

How to find memory leaks and inefficient memory usage?

Thank you. To find memory leaks and inefficient memory usage, you can use tools such as the debugger-integrated Memory Usage diagnostic tool or tools in the Performance Profiler such as the .NET Object Allocation tool and the post-mortem Memory Usage tool.

Does Visual Studio 2015 support native memory leak detection?

Native Memory Leak Diagnostics in Visual Studio 2015. Visual Studio 2015 makes native leak analysis a lot easier for most developers. You will still need UMDH or ETW for production debugging and leak detection, but in the comfort of your development workstation, Visual Studio should be able to suit your needs.

How to check and monitor memory leak on Linux?

The selection of tools would vary based on your requirement. There are many other tools such as YAMD, Electric fence, gdb core dump etc which can help you capture memory leak. Lastly I hope the steps from the article to check and monitor memory leak on Linux was helpful.


1 Answers

The Troubleshooting guide for Java SE 6 with Hotspot VM contains a fairly elaborate section on techniques to aid in detecting native memory leaks. These include:

  • wrapping all memory allocation and deallocation calls to track the amount of memory used.
  • relying on platform specific support like the debug support provided by the Microsoft Visual C++ compiler or on mtrace (and MALLOC_TRACE) to debug memory allocations on Linux.
  • using memory leak analysis tools like Rational Purify.

among others. Notably, the article mentions that no ideal solution exists for all platforms.

Also, consider using the -Xcheck:jni flag that appears to be available in most JVMs. The -X flag itself indicates that the flag is non-standard, but the flag appears to be available in the IBM JDK, Oracle JRockit R28, and even the Oracle/Sun JVM. Enabling the flag switches on a mode where wrappers are added around JNI calls, thereby allowing you to track illegal arguments passed to JVM calls as noted in the JNI programmers' guide and specification. While, it's use in detecting memory leaks is subjective, it would definitely help if you suspect that the leak is being caused due to invalid parameters being issued.

like image 126
Vineet Reynolds Avatar answered Oct 16 '22 18:10

Vineet Reynolds