Java Agents have a big advantage in their tracking depth but are much more complicated to write. Check out this introduction to Java Agents to see how this all works.Īspect profilers are pretty easy to set up, but they are limited in what they can monitor and are encumbered by detailing out everything you want to be tracked. This allows for any code running in your application to be instrumented-be it code you wrote or 3rd-party libraries your application depends on. This method has greater access to your application since the code is being rewritten at the bytecode level. Java Agent profilers use the Java Instrumentation API to inject code into your application.For an example, see Spring AOP Method Profiling. These profilers are simple to set up but you need to know what to profile. The injected code can start a timer and then report the elapsed time when the method finishes. Aspect Profilers use aspect-oriented programming (AOP) to inject code into the start and end of specified methods.Lightweight profilers take a different approach at tracking your application by injecting themselves right into the code. Products like XRebel and Stackify Prefix. They slow down your application a good deal of processing power is required for the high level of detail provided.(Note: some profilers can work off thread and memory dumps in a limited fashion.) Requires a direct connection to the monitored JVM this ends up limiting usage to development environments in most cases.Good for tracking CPU usage, a Java profiler usually provides a CPU sampling feature to track and aggregate CPU time by class and method to help zero in on hot spots.The ability to manually run garbage collection and then review memory consumption can easily shine a spotlight on classes and processes that are holding on to memory in error. Great for tracking down memory leaks, standard profilers detail out all memory usage by the JVM and which classes/objects are responsible.This allows a developer to dive into the call structure at whatever angle they choose. JVM profilers will track all method calls and memory usage. This depends on the type of debugging task. Overall, I’m glad that there’s another free tool out there for Java profiling.Products like VisualVM, JProfiler, YourKit and Java Mission Control.Ī standard Java profiler certainly provides the most data, but not necessarily the most useful information. I also did not see much Thread blocking information displayed but I didn’t spend too much time with VisualVM, maybe it’s there. One thing that was missing in VisualVM was the “GC roots” option in YourKit. VisualVM Thread and Heap DumpĪnd finally, the Heap Dump showed me the classes taking up the memory, just what I needed… VisualVM Classes View The Heap and Thread dump is as easy as right clicking on the application and it was fast and seemed accurate. The main view included CPU, memory, classes and threads graph as you would expect from a profiler. First, I didn’t have to do anything special to use it, no JVM options or anything like that to make it detect my running Tomcat, it was just displayed under applications: VisualVM Applications View I was pleasantly surprised with the VisualVM. I think it comes with JDK on Windows, but not on Mac OS, so I had to download it. Luckily, a coworker recommend Sun’s free VisualVM. This didn’t help me of course, so I turned to other tools. I’m guessing that since the server is under load, by the time YourKit could take the snapshot, the data was not relevant anymore. I could see the memory usage in the main graph but when I took a snapshot of the heap, the snapshot took a while, and it didn’t match with the graph I was observing. This time though I had to do profiling when server was under load and YourKit did not behave as I expected. Normally I use YourKit, easy to setup, and it has all the tools I need to do profiling such as CPU and Heap display graphs, force GC option, display of objects with their instance counts and sizes and so on. In the last couple of weeks, I had to do lots of profiling of our server code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |