Date: Thu, 21 Feb 2008 22:29:37 -0800 (PST) From: Nick Johnson <freebsd@spatula.net> To: Mika Nystrom <mika@async.caltech.edu> Cc: freebsd-java@freebsd.org Subject: Re: Memory leak in 1.5.0 JVM Message-ID: <20080221222313.O2617@turing> In-Reply-To: <200802220549.m1M5nJhd085207@camembert.async.caltech.edu> References: <200802220549.m1M5nJhd085207@camembert.async.caltech.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 21 Feb 2008, Mika Nystrom wrote: > Out-running the garbage collector? I'm not used to Java, but in > Modula-3, the garbage collector gets called when you allocate memory, > is that not how it works in Java? In a word, no. Garbage collection in Java is asynchronous. In the Sun JVM there are several different garbage collection strategies. The default strategy uses multiple "generations"-- a "new" generation for short-lived objects; those objects that live through a new generation collection get promoted to one of many "survivor" spaces, and those that survive collection there (either because of time or exhausting the size of the survivor space) get promoted to the "tenured" or "old" generation. Then there's a "permanent" generation for classes and other stuff. If you just sit and watch the memory size of a JVM process, it might appear to be "leaking" memory, but what's happening under the hood is far more complicated than that. The JVM will also grow to accomodate the amount of memory it has needed to allocate, but won't necessarily -shrink- again once those objects are garbage collected. In a long-running process, chances are that if a program needed 256M once, it's going to need it again. To get a real good idea of what's going on under the hood, look at tools like jvmstat and visualgc. This document will give you a much more detailed view than my rough outline here: http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html Nick -- "Courage isn't just a matter of not being frightened, you know. It's being afraid and doing what you have to do anyway." Doctor Who - Planet of the Daleks This message has been brought to you by Nick Johnson 2.3b1 and the number 6. http://healerNick.com/ http://morons.org/ http://spatula.net/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080221222313.O2617>