Bitterblue
Bitterblue

Reputation: 14075

Java Garbage Collection Time?

I have a very performance sensitive application in Java. (I know I should actually use C or something else. But it's Java now.) I'm trying to avoid creating and throwing away objects. Now I need to know how much garbage collecting is going on still.

How can I find out ?

If possible I would like to have a sort of number in milliseconds or nanoseconds something that doesn't require installation of more software.

Upvotes: 11

Views: 16193

Answers (4)

kosa
kosa

Reputation: 66637

You can use tools like VisualVM to monitor application activity. Make sure you are using appropriate GC alogorithms.

Oracle JVM provides multiple types of Garbage Collectors:

  • The throughput collector
  • The concurrent low pause collector
  • The incremental (sometimes called train) low pause collector:

Read more on these collectors here.

Upvotes: 8

Ivan Senic
Ivan Senic

Reputation: 649

Or you can let JVM print the GC activity.. These settings I have:

-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -Xloggc:logs/gc.log

GC activity is printed to a file logs/gc.log..

Upvotes: 9

Suresh Atta
Suresh Atta

Reputation: 121998

Jprofiler ,which Enables both memory profile to assess memory usage and dynamic allocation leaks and CPU profiling to assess thread conflicts.

Upvotes: 1

Stephan
Stephan

Reputation: 8090

You can use VisualVm for this, it is exactly what you need.
As you can see below you have GC activity which is very useful:

enter image description here

Beside the GC Activity you have a lot of details there like : heap usage, cpu usage, object instances usage etc.

Upvotes: 2

Related Questions