javagirl
javagirl

Reputation: 1675

What's the default schedule of GC in java 6? (1.6.0-25)

I'd like to know what is approximately the default schedule GC runs on java 6 (64bit) machines? I know it can be triggered without any schedule, but still, what would be the default behaviour?

I don't know if the java runs as with -server option. How can I check that? I don't see it in the java process command (when I do 'ps ax|grep java'), but still, can it be run in server mode anyway? Does it depend on a jvm installed, or the type of the physical server? Please let me know how can I know this.

Upvotes: 3

Views: 7381

Answers (3)

Aleš
Aleš

Reputation: 9028

First, to print all the default JVM settings, use : java -XX:+PrintFlagsFinal -version

By default, JVM Hotspot runs in the -client mode.

You can use the following parameters when starting your script -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log to obtain a log containing all the properties/arguments set at the VM startup.

Regarding the GC, the defaults are determined by the JVM Ergonomics, see Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning. In short :

If not otherwise set on the command line, the initial and maximum heap sizes are calculated based on the amount of memory on the machine, the default maximum heap size will not exceed 1GB, regardless of how much memory is installed on the machine.

In the same document, the chosen GC algorithm depends on the hardware setup, the VM will decide between Serial and Parallel collectors. To see which one is running in the end, enable GC logging.

And, you should check out the following Q/A: How is the default java heap size determined?

Upvotes: 4

Peter Lawrey
Peter Lawrey

Reputation: 533492

If you are creating 10 MB/second of garbage and you have a 100 MB Eden space it will take 10 seconds to fill up and you will see a GC every 10 seconds. Create less garbage or make the Eden space larger and the interval between collections will be higher.

There is a default timer of one hour this is called the "DGC". If no collection occurs for an hour, a full GC can be triggered to clean up any distributed objects. I usually have this set to a week.

The defaults are

-Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000

BTW As I design low latency systems, I make the Eden space larger than the amount of garbage created in a day. I do a full collection triggered in code once per day when the system is not being used. This way you will see no collections, minor or major during the day.

Here is an example from a real low latency trading system in Java.

http://vanillajava.blogspot.com/2011/06/how-to-avoid-garbage-collection.html

BTW Java 6 update 25 is pretty old now and I would consider Java 6 update 45 if not Java 7 update 40.

Upvotes: 2

isnot2bad
isnot2bad

Reputation: 24444

Info about garbage collector: http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html

If you want to know if your VM runs in server mode:

java -version

Then look for something like:

Java HotSpot(TM) 64-Bit Server VM (...)

Upvotes: 2

Related Questions