How to attach VisualVM and start profiling immediatedly with application start? - java

I can attach VisualVM to a running application, then start profiling.
All this time while I am performing manual operations, the target application is running and statistics is loosing.
How to begin collecting statistic exactly at the same moment application starts?
UPDATE
With Profile Startup what is the way to set which class to run?
Very small cell for application setup says
-agentpath:D:/Apps/visualvm_138/profiler/lib/deployed/jdk16/windows-amd64/profilerinterface.dll=D:\Apps\visualvm_138\profiler\lib,5140
i.e. contains no clues to application location.

You can try the startup profiler plugin:
https://visualvm.java.net/startupprofiler.html

Related

Can JProfiler be run without the GUI?

Is it possible to run JProfiler to profile an application without having to launch the GUI, select the application, etc?
I'd like to be able to run a set of executions of my application and save the profiling results in an automated way.
Thanks
You can use the offline profiling capability from JProfiler:
JProfiler's offline profiling capability allows you to run profiling sessions from the command line without the need for starting JProfiler's GUI front end. Offline profiling makes sense if you want to
perform profiling runs from a scripted environment (e.g. an ant build file)
save snapshots on a regular basis for QA work
profile server components on remote machines via slow network connections
Reference: JProfiler Docs

Debug a running java application in eclipse?

I am developing a java application which gathers some data, processes it and serialize them every 30 minutes into a file which makes it a time sensitive in that way. During the test mode, this writing-to-file feature is disabled.
I started the application by mistake in test mode and it is running since last few hours collecting data in memory but data isn't written into file as application is running in test mode. Though it would keep collecting data until it writes it into a file, which would never happen.
Is there a way to change the execution mode from "run" to "debug" or pause it and run some operations on in-memory data such as run a method manually that write them in a file?
Sorry to say, but no. When you run in debug mode, the JVM is started in such a way that a debugger can interact with the running classes. An already running JVM would not allow those collaborations post-startup, partially by inadvertent design and partially as a security measure.

Tomcat java web application got running slowly

Don't know which way of investigation should select.
After some time (near 4 weeks) on continouous running web application got run slowly.
Checking:
catalina.out - no full gc.
Regular gc takes near 0.2s and executed one time in near 10 - 30 seconds.
On the same server another tomcat with web application running well.
So the problem not in the host.
I am really confused. What should be checked ?
you can use a visualvm to track you tomcat performance, you have to add the JMX parameters to allow you to connect the visualvm to you your tomcat.
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=8484
-Dcom.sun.management.jmxremote.ssl=false
In the visualvm >> Threads Tab you will see a button in the above right corner Thread Dump, this button generates a file called thread dump, this file contains the whole threads that currently live, generate a multiple thread dumps and trace you application threads, you will clearly see what does the slow thread is currently doing, which exactly the method caused that slowness.
I hope this help you to get the root cause for your slowness.

Reload Tomcat webapp automatically?

Is it possible to configure web.xml to reload a specific tomcat webapp at a particular time automatically. If not, is it possible to do this programatically?
Programatically - an option is to write an Ant script for reload the webapp you want based on the example given on the Tomcat docs
So you'll be left with a command like
ant -Dpassword=secret reload
and put this into a cron tab on your server (if Unix/Linux) or Windows Task Scheduler for windows.
I notice you've tagged your question garbage-collection. If you are redeploying the web app due to excessive GC, then its better to tackle the root cause of the issue since this reload is only a workaround.
Run a profiler to identify memory leaks.
Related Reading on Memory Issues / GC
Java memory leak
When log shows a lot of GC hits, what code change shall we need?
Ways to reduce memory churn

Slow Startup for Java Web Start Application

I'm using the Netbeans IDE to develop a Java Web Start application that will launch from the web and then use the EclipseLink JPA to access a remote MySQL database. I'm using the Swing Application Framework to manage life cycle for my app.
When I launch the application from Netbeans it takes about 7 second for my application to load, but when I use the Netbeans IDE to create a Web Start distribution package (with the JAR and JNLP files) it takes about 60 seconds to launch. Also, the "verifying application"/"downloading application" progressbar window seems to run every time I launch the app even though a copy of it has already been cached.
From the users point of view, one first sees my splash screen for 1 to 2 seconds, then the "verifying application"/"downloading application" progressbar window for 5 to 20 seconds and then nothing for a good 40 seconds before the application launches.
The app code is written such that it should show itself BEFORE the JPA starts loading the persistence unit (so I doubt that's the problem), but I thought I'd mention it just in case.
Update: Method createEntityManagerFactory Slow With Web Start
Having looked into this further, I've found that the method createEntityManagerFactory--which is necessary for EclipseLink to connect to MySQL--takes aboutn 5 seconds to execute when I run the applicaiton from Netbeans or when I remotely log in to my server to launch the JNLP there, but when I run the application via the web the same line takes 35 seconds (hugely delaying startup). Interestingly, this time gets even worse as my internet connection speed gets worse. Below is a copy of the JNLP file I'm using.
Does anyone have any idea what may be causing such a delay?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
MyApp
My App Vendor
My App Description
MyApp
I'm not sure if you solved this yet. But, I repeated your problem and fixed it. All I had to do was switch from Eclipselink to Toplink. That simple. Startups went from 1 to 2 minutes down to 5 seconds. I even traced the app and found the same hanging during the init of eclipselink.
Hope it helps.
First of all, in the Java Control Panel enable ALL logging. This will allow you to see exactly what Java WebStart is doing (but much of it doesn't make much sense unless you have access to the WebStart source).
My guess from your description is that you have one or more unreachable DNS servers in your network configuration AND you want to access a network resource that isn't available.

Categories

Resources