Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote profilling java application

I'd like to ask how I can profile REMOTELY a java application. For debugging I can say which port the JVM must listen etc since the machine I'm trying to access is behind an ssh gateway so I manually create an SSH tunnel but I've been googling about the same thing but when profiling and I couldn't seem to find. Basically I'm looking for the equivalent of this command:

java -agentlib:jdwp=transport=dt_socket,server=y,address=8000 -jar /bla/bla 

but for profiling so that I can remotely attach a profiler.

like image 361
LordDoskias Avatar asked Sep 27 '11 14:09

LordDoskias


People also ask

What is profiling Java application?

Profiling is the process of examining an application to locate memory or performance-related issues. When profiling a Java application, you can monitor the Java Virtual Machine (JVM) and obtain data about application performance, including method timing, object allocation and garbage collection.

What is remote profiling?

Remote profiling is the case when the profiled application and the profiler UI run on different machines, usually on a server and your developer machine.

Which of the below Cannot be used profiling Java applications?

Which of the below is not a Java Profiler? Explanation: Memory leak is like holding a strong reference to an object although it would never be needed anymore. Objects that are reachable but not live are considered memory leaks.

How do Java profilers work?

Sampling profilers work by periodically querying the JVM for all the running threads and getting the stack trace for each thread. It then determines what method each thread was executing when the sample was taken and compares the samples to determine how much time was spent in that method.


1 Answers

Disclaimer: My company develops JProfiler

With JProfiler, the VM parameter is like this:

-agentpath:/path/to/libjprofilerti.so=port=8849

"/path/to/libjprofilerti.so" is the path to the native agent library, on Linux x86, for a 32-bit JVM it would be [JProfiler installation directory]/bin/linux-x86/libjprofilerti.so. With the port parameter, you can tell the agent to listen on a specific port. You can set this to the port of your SSH tunnel.

You can easily generate this VM parameter by invoking Session->Integration Wizards->New Remote Integration in JProfiler's main menu:

enter image description here

On your local machine, you create a new session of type "Attach to profiled JVM" and choose the local port of your SSH tunnel (10022 in the screen shot):

enter image description here

like image 55
Ingo Kegel Avatar answered Oct 03 '22 18:10

Ingo Kegel