I would like to get a memory snapshot at a very specific point in time, i.e. at my break point.
But I can't seem to find the necessary buttons/configuration to start the profiling in debug mode.
Using Eclipse and JProfiler 7.
Edit: More info:
Use
Sessions->Integration Wizards->New Remote Integration
in the JProfiler GUI to get the VM parameter for profiling and add that to the VM parameters of the debug run configuration in eclipse. When the run configuration is started, it will wait for a connection from the JProfiler GUI.
Related
I am attempting to hook up JProfiler GUI on my local machine(Windows x64) to a JProfiler agent running on a remote (Windows x64). The remote machine has 2 JVMs - one a JBOSS JVM and another as a Java Application as a Windows Service via wrapper services of YAJSW. These JVMs are started Windows User Profile 1.
I pasted the JProfiler agent zip file on the remote machine and logged into it via mstsc. When I run the jpenable command in cmd (As admin) and it asks me to search for "already running JVMs" - I press 'y' but the cmd window automatically closes out. When I force jpenable to run with the PID of either of those JVMs - it complains that the JVMs cannot be seen by this user. Even using User Profile 1, JProfiler could not see the JBOSS JVM or the other JVM (with Show Services option) with the error message - 'No unprofiled JVMs found'.
My question is - if we have got JVMs on a remote machine started by 1 user, and I attempt to run the JProfiler agent (through jpenable) with user 2 , how can I have the agent see both JVMs to start up profiling so that I can hook up my local JProfiler GUI to either of these JVMs.
Much Appreciated !
You have to find the JProfiler attach helper service in the service manager and change its user account to the same user account that is used to start JProfiler. Then JProfiler should be able to show the process in jpenable if you tell it to search for services.
Update for JProfiler 10.0+:
Since JProfiler 10.0, it is possible to attach to services that are not started by the LocalSystem account. JProfiler can now attach to all services, started by admin and non-admin users.
We have some Java code that starts a new process using the following code: Runtime.getRuntime().exec(command); I'd like to be able to tell the debugger that it should follow the child process like you can do with GDB as documented here by issuing the set follow-fork-mode child command.
Is there something equivalent in the IntelliJ IDEA Java debugger? If so how do I configure it?
Thanks
Java doesn't provide an automated way to debug processes and their child processes. One needs to run the child process with the JVM options to enable debugging. IDEA Remote Debug configuration will suggest the proper options to use. Once the process is started with the appropriate options you can connect to it from IDEA with the Remote Debug configuration.
Sample options:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
You may want to start with suspend=y so that the execution is suspended until you connect with the debugger.
We now have this Intellij plugin that uses a java agent to automatically start all child processes in debug mode.
It listens for any debugee processes on 7857, then attaching debugger to those processes.
Install AttachMe
To enable automatic mode, run this first, source ~/.attachme/conf.sh
Afterwards start AttachMe listener
Test it with maybe a Play application in prod mode (assuming play plugin is enabled), do sbt start. Play in prod mode forks another JVM process. Debug points should now hit.
I've search around, read relevant questions on this site and others, but have failed to find a solution. It strikes me odd that one does not exist so let me detail my question here:
I use Junit4 + Eclipse regularly to test my code. In some cases, certain tests can take a lot of CPU and/or memory, rendering my workstation unusable for the duration of the test. This is a pain I'm trying to solve.
I'm looking to get the exact same behavior but through a remote server. I want:
To still be able to set breakpoints and debug my app.
To see how the tests progress using the Junit view in Eclipse.
Click on a button have the tests started (build process and copying of files is allowed, but only if efficient).
In my mind I envision something that rsyncs the files to the remote server, starts the java process there with the exact same arguments as it would on my local machine, makes the debug port available (not just localhost) and has eclipse hook up to it to have both debug and junit view working.
How can I get this done?
Several leading questions that may help us find a solution:
How does Eclipse communicate with the java process when run locally (for both debug purposes AND the Junit view)?
How can I involve myself in the process of spawning the java process for the JUnit testing so I can copy the required files over to a remote server?
How can I make the process spawn remotely instead of locally?
How can I have Eclipse hook up to the remote host instead of the localhost?
The easiest would be to invoke command line JUnit runner on remote mashine using the following command:
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8998,server=y,suspend=y -cp ... org.junit.runner.JUnitCore <test class name>
So, it will wait til you attach remote debugger from Eclipse at port 8998.
You can also use Eclipse's Target Management tools to transfer files to remote system and launch remote commands. There is several tutorials on the project page.
You could set up a jenkins CI server, sync your code via git (or just copy using ftp or something), execute the test in a jenkins job triggered by a git-hook or through some script. Then remote debug into the running test process like Eugene Kuleshov suggested. This process could be automated by an ant-script which you invoke from eclipse. There should be a mylin connector (for example) through which you can monitor the running tests. I don't know if it is possible using the standard JUnit view of eclipse to see the running tests without using some custom plugins (if any exist).
Try vs code remote ssh extension for this.
I'm starting tomcat from inside netbeans. I'd like to monitor the heap usage on that instance of tomcat so I fire up jVisualVM. However the process isn't listed. Any ideas?
Are you using Java version 6u24? Then you may fall victim to this bug which will be fixed in 6u25 (in a nutshell, jVisualVM can't find your process' hsperfdata).
Otherwise, you have to enable monitoring via JMX:
Pass the following JVM parameters to Tomcat:
-Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
Then add the remote process to jVisualVM via File -> Add JMX Connection. You can connect to the process using port 8888
jVisualVM has some other gotchas, e.g. the user starting jVisualVM needs to be the same as the user owning the process you want to monitor (although, I don't think this is your issue). See more here.
I'm having trouble using the Netbeans 6.5 profiler to profile the memory usage of a java web app, remotely.
I have followed the steps in the tutorial, and was able to customize a Tomcat instance to start with the profiling agents. I can also attach the Netbeans profiler to the running server: for some seconds, the profiler shows graphs with the memory usage of the server.
However, I am not able to run my deployed web app. After a few seconds, the server is shut down gracefully as if it simply had reached the bottom of its method main (hardly the expected behavior of a web server).
During these seconds, the server is not responsible, and I can't connect to a web application in it, they are simply not deployed.
I do not want to import my app into a new Netbeans project just for profiling it. It's possible to profile a remote app without access to its source, right ? After all, for a few seconds, the server was running and being profiled.
I want to profile a web application in Netbeans 6.5. What did I forget ?
You can use VisualVM tool as well. Follow the below mentioned steps.
1) Run jstatd ( jstat demon process) ( Run on your remote machine where application is running)
jstatd -p 1098 -J-Djava.security.policy=tools.policy ( specify unused port ) if tools.policy file is not specified create it as follows.
tools.policy
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
2) Also specify the following properties before you start your JVM.
#JMX property
JVM_ARGS="${JVM_ARGS} -Dcom.sun.management.jmxremote=true"
JVM_ARGS="${JVM_ARGS} -Dcom.sun.management.jmxremote.port=10992"
JVM_ARGS="${JVM_ARGS} -Dcom.sun.management.jmxremote.authenticate=false"
JVM_ARGS="${JVM_ARGS} -Dcom.sun.management.jmxremote.ssl=false"
3) Start the visual VM on local machine.
a. Under remote tab add remote node.
b. Wait for couple of minutes you will see all the core applications instance will be seen under remote tab.
c. Click on remote node then select Add JMX connections specify node:port (port mentioned above in point 2.)
d. Wait for few seconds you will see JMX connection under remote node.
4) After few seconds you will see new tab appearing under remote node. Double click on the remote_node:10992 you will see the profile table on right hand side.
You can see memory , cpu , thread etc details ..
Are profiling the entire webserver or did you use the profiling filter to profile only your package?
Reducing the interaction between the profiler and the app server itself can solve it.
Check your jvm version. The version used by netbeans should be same as that in tomcat.
Use default ports. If you have changed any ports ensure they are above 1024.
Try to profile the example application in tomcat (remove all other applications). If it is running sucessfully it means there is a memory constraint.
Profiling requires huge memory. use -xms1024m -xmx1024m for tomcat.
If every thing else fail. think of switching to jdk6 and tomcat 6.
After many trials I discoverd that there are lot of limitations in jdk5 and tomcat5. switching to tomcat6 and jdk6 solved the problem for me.
Profiling with netbeans does not work jrockit, ibm jdk etc..
--kiran.kumar