Server Profiling with VisualVM for MyEclipse
MyEclipse includes an advanced integration of Sun’s VisualVM Profiler. Server profiling allows you to gather data about applications as they run and monitor data statistics.
Note: Server Profiling was removed in MyEclipse 2015 and subsequent versions.
- Profile a stand-alone Java application
- Profile a web application
- Profile a Java applet
- Select Help>Choose Components.
- If VisualVM is not installed, add the component by selecting it on the left and moving it to the right side.
- To be reliably profiled, your application must be executed using JRE 1.6.0 update 7 or higher.On the Selected side, type vm in the Filter field to find the MyEclipse VisualVM Profiler components.
2. Profiling a Stand-Alone Java Application
- Select MyEclipse>Examples On-Demand to download an example project for profiling.
- Click Search, and search for swing.
- Click the Install button for the Swing Contact Manager example to install it into your workspace.
- Right-click the M4MContactManagerExample project, and select Profile As>Java Application. This launches the profiler in performance profiling mode.
- Select Main – com.myeclipseide.examples.m4m as the main class, click OK, and select Performance as the profiling mode. Click OK to continue.
- Select a few names in the contact manager application to observe profiling information being collected in the VisualVM window.
- Select a name in the list, and click Remove to see the removeButtonActionPerformed method added to the list, with 1 as its invocation count. This count increases each time you click Remove.
- Click to save a snapshot of the results collected at this time. Use the filter to display only the information you want to view. You can save this to a file for later research.
- Close both the application and VisualVM window.
To run the profiling session again, you can repeat step 1, or click the drop-down arrow on the Profile icon . Select the profiling configuration you want to view. If an application that was previously being profiled is still running, you are prompted to shut it down before launching another profiling session.
- Right-click the project, and select Profile As>Profile Configurations, or click the drop-down on the Profile icon , and select Profile Configurations.
- Select your application from the list on the left, under the Java Application node.
- Select the Profile tab, and then the Performance tab to change the profiler settings.
|Profile from||This field specifies root methods the profiler uses to instrument your application. Only root methods and methods they call (recursively) are instrumented while the rest of the application continues to run un-instrumented. Use the Add button to specify a method, class or package. If a class is specified, then all methods in that class become instrumentation roots. If a package is specified, methods in all classes contained in that package become instrumentation roots (depending on your selection in the Profiling Root wizard, this could mean only the selected package or include sub-packages, as well). By default, MyEclipse specifies a root that includes all packages in your project.|
|Only / Do not profile the following classes||The profiling filter controls the packages which are (or are not) profiled. Besides the root methods themselves, profiling data is only collected and displayed if methods satisfy the filters defined here.|
Instrument method invoke() If enabled, all calls made using reflection (java.lang.reflect.Method.invoke()) are followed and instrumented.Instrument getters / settersEnables instrumentation of getter and setter methods.Instrument empty methods Enables the instrumentation of methods that do not contain executable code.Profile new threads / runnablesIf enabled, the run() method of every runnable is treated like a root method, causing all methods called by it to be instrumented as well.Exclude time spent in Thread.sleep() and Object.wait() If selected, these methods are not profiled.Limit number of profiled threads Profiling data is only collected from registered threads. Whenever an unregistered thread enters instrumented code, it is registered. When the number of registered threads reaches the specified limit, further registration stops. This counter can be reset by resetting the collected results in the profiler.
- Right-click the project, select Profile As>Profile Configurations, and select your project from the list on the left under the Java Application node.
- Select the Profile tab, and then select the Memory tab.
- Customize the settings, and then click Profile to start memory profiling.
|Record object creation only||When selected, the profiler collects information about the number, type and location of allocated objects. All classes currently loaded by the target JVM (and each new class as it is loaded) are instrumented.|
|Record object creation and garbage collection||If this option is selected, in addition to the data presented by the above option, you are also given information about object liveliness, i.e. how many objects of a given type are still alive. Profiling garbage collection in addition to object creation increases the profiling overhead.|
|Track every X allocations||While the number of allocated objects of a particular class is accurately tracked, complete profiling data is separately tracked and is only collected for every X th object (of that class) allocated. To record information about each allocation, this figure can be set to 1, though that increases profiling overhead significantly. By default, MyEclipse tracks every 10 th object allocation.|
|Record stack trace for allocation||If enabled, when object creation is recorded, the call stack at that time is also recorded. By default, the entire call stack is recorded, but the Limit Stack Depth to X Frames option can be used to limit the number of frames and reduce profiling overhead.|
- Right-click a web project, and select Profile As>MyEclipse Server Application.
- To customize the profiling settings, follow the instructions in Section 2. Profiling configuration for your web application is found under the MyEclipse Server Application node in the Profile Configurations window.
- Right-click an applet project, and select Profile As>Java Applet.
- To customize the profiling settings, follow the instructions in Section 2. Profiling configuration for your Java applet is found under the Java Applet node in the Profile Configurations window.