Skip to content

Profiling remote Spring Boot app with memory allocation stack traces #644

@eftewuer

Description

@eftewuer

I have a Spring Boot 3.5.4 application running on remote linux machine 192.168.1.10 on java 17.0.16. I can open it in my local (192.168.0.5) linux machine using VisualVM version 2.2 (also on Java 17.0.16)-> Add Remote Host and then Add JMX Connection and providing 192.168.0.10:22001 as the connection string. This works without problems but when I want to profile the memory allocations I only get the list of allocated objects without stack trace (to find which other objects allocated them - something that is available by default when profiling local application).

This scenario works when I start the remote application with these parameters:

java -Dcom.sun.management.jmxremote \
 -Dcom.sun.management.jmxremote.port=22001 \
 -Dcom.sun.management.jmxremote.rmi.port=22001 \
 -Dcom.sun.management.jmxremote.local.only=false \
 -Dcom.sun.management.jmxremote=true \
 -Dspring.jmx.enabled=true \
 -Dcom.sun.management.jmxremote.authenticate=false \
 -Dcom.sun.management.jmxremote.ssl=false \
 -Djava.rmi.server.hostname=192.168.0.10 \
 -jar demo-hello.jar

After some reading and GPT-ing it looks that in order to see memory allocations stack traces for remote app I need to start it with profileinterface parameter, so after many try&fail I got to the following command line params (see -agentpath and -Xbootclasspath):

java -Dcom.sun.management.jmxremote \
 -Dcom.sun.management.jmxremote.port=22001 \
 -Dcom.sun.management.jmxremote.rmi.port=22001 \
 -Dcom.sun.management.jmxremote.local.only=false \
 -Dcom.sun.management.jmxremote=true \
 -Dspring.jmx.enabled=true \
 -Dcom.sun.management.jmxremote.authenticate=false \
 -Dcom.sun.management.jmxremote.ssl=false \
 -Djava.rmi.server.hostname=192.168.0.10 \
 -agentpath:/home/tom/libprofilerinterface.so=/home/tom,22002 
 -Xbootclasspath/a:/home/tom/jfluid-server-15.jar:/home/tom/jfluid-server.jar
 -jar demo-hello.jar

Problem: with these parameters the application hangs during startup:

Profiler Agent: Initializing...
Profiler Agent: Options: >/home/tom,22002<
Profiler Agent: Initialized successfully
Profiler Agent: 250 classes cached.
Profiler Agent: Waiting for connection on port 22002 (Protocol version: 21)

It means it is not available on JMX port (22001) so it is unavailable in VisualVM GUI (it is greyed out). The apps keeps listening on port 22002 for profiler connection.

How can I make the app starting up completely without "Waiting for connection on port 22002"?
Is the scenario of remote application profiling with memory allocation stack traces supported or is it only for profiling local applications? How to make it work? Maybe I should do it completely different way?
Thank you in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions