Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java hprof question

What is the difference between using -agentlib:hprof=cpu=times vs -agentlib:hprof=cpu=sample when running a java class? I know that cpu=sample causes the jvm to sample the call stack at regular intervals, but what does cpu=times do?

like image 504
Nathaniel Flath Avatar asked Dec 17 '08 17:12

Nathaniel Flath


People also ask

What is a Java Hprof?

HPROF is a demonstration profiler shipped with the IBM® SDK that uses the JVMTI to collect and record information about Java™ execution. You can use HPROF to work out which parts of a program are using the most memory or processor time.

What is Hprof used for?

HPROF is a tool for heap and CPU profiling shipped with every JDK release. It is a dynamic-link library (DLL) that interfaces with the Java Virtual Machine (JVM) using the Java Virtual Machine Tool Interface (JVM TI). The tool writes profiling information either to a file or to a socket in ASCII or binary format.

How do I view an Hprof file?

If you have a heap dump file saved on your local system, you can open the file in Java VisualVM by choosing File > Load from the main menu. Java VisualVM can open heap dumps saved in the . hprof file format. When you open a saved heap dump, the heap dump opens as a tab in the main window.

Why Hprof files are created?

hprof files generated in log folder in BI servers. hprof files are heap dump of the memory of java-based processes. Huge hprof files most commonly indicate out of memory issues about the related processes.


1 Answers

hprof=cpu=times causes the profiler to count the number of times each method was called and measure the time spent in each method.

Read about it here (using browser's find function: cpu=times).

like image 191
Bill the Lizard Avatar answered Sep 29 '22 12:09

Bill the Lizard