How does a Java profiler work?
A Java profiler uses a native interface to the JVM (the JVMPI) to get profiling information from a running Java application. The native library is loaded and initialized by adding a special directive to the command line (-Xrunjprofiler). As your application runs, the native library receives various types of events from which it builds its profiling database. JProfiler’s GUI frontend connects to the profiled application through a socket and queries the profiling database according to your selections.