Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats a good java debugger?

I'm trying to find memory leaks and performance issues with my java application. Is there a program out there that can help me debug my application and display performance results?

Thanks.

like image 353
Kyle Avatar asked Aug 28 '10 06:08

Kyle


People also ask

Is there a debugger for Java?

The Java Debugger, jdb, is a simple command-line debugger for Java classes. It is a demonstration of the Java Platform Debugger Architecture that provides inspection and debugging of a local or remote Java Virtual Machine.

How do you debug a Java program?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application.

Is Java easier to debug than Python?

There is more experimentation than production code. Java is a statically typed and compiled language, and Python is a dynamically typed and interpreted language. This single difference makes Java faster at runtime and easier to debug, but Python is easier to use and easier to read.


2 Answers

Have a look at jvisualvm in the JDK - a subset of the Netbeans profiler - which can attach to a running Java 6 process and allow you to profile it and do memory analysis.

https://visualvm.dev.java.net/gettingstarted.html

like image 162
Thorbjørn Ravn Andersen Avatar answered Oct 05 '22 08:10

Thorbjørn Ravn Andersen


I used a lot of tools to find why my program eats 100+ Mb of ram, polished the code to remove any possible memory leaks. Later I found that once jvm took some memory from the OS, I doesn't always return it, even if that memory is not used, which often looks like a memory leak. This depends on -Xmx and -XX:MaxHeapFreeRatio. I set Xmx to 40 which is roughly how much memory my app should use, and memory usage stays within 10-15 Mb of this range instead of increasing uncontrollably.

Also, jconsole is a great tool. It comes with jdk.

like image 44
Denis Tulskiy Avatar answered Oct 05 '22 08:10

Denis Tulskiy