views:

91

answers:

2

I've been told by my company's support team that some versions of java have a significant performance impact when we turn on -verbose:gc. However I can't figure out if this is the case or not.

Was this logging slow(ish) at some point, and when did it stop?

The reason I ask is that there's some hesitation about applying this to a production environment to investigate potential memory leaks (and whether we can stop doing periodic restarts of the system...).

Specifically I'm talking about Java 1.4.2 which I think introduced the argument, and what service pack it applies up to.

+4  A: 

I know you asked about the impact of verbose:gc (Amir is correct), but based on the comments I see you are investigating a memory leak.

Is it possible for you to get a histogram of your environment? verbose GC will only show you that there is a memory leak, not where the memory is sitting.

you mention java 1.4.2, is that your current version? If you are using 1.5 or higher you can use

jmap -histo <pid> > file.txt

This will give you a breakdown of all the objects in memory. You will freeze your JVM for a time dependent on the amount of memory in the system. (2GB can freeze for a minute or so on even good hardware) test this on a development system first. I know you don't want to impact your production environment but this is a necessary evil to find the source of the problem. Do a capture right before the periodic restart to lesson your impact.

Sean
+2  A: 

I suggest that you do the following:

  1. Write some benchmark that is likely to stress the garbage collection. (Create large linked data structures with weak references, etc, etc).

  2. Install a copy of the same version of the JVM as you are using in production on some test box.

  3. Run the benchmark with various GC logging settings, including the settings that you want to run in production, measuring the performance impact on the benchmark.

If you do this right, it will give you some solid evidence about what the likely performance impact will be for your production server.

Stephen C