From owner-freebsd-java@FreeBSD.ORG Fri Feb 22 06:43:07 2008 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29A4516A406 for ; Fri, 22 Feb 2008 06:43:07 +0000 (UTC) (envelope-from freebsd@spatula.net) Received: from turing.morons.org (turing.morons.org [208.96.51.42]) by mx1.freebsd.org (Postfix) with ESMTP id 0C41313C45D for ; Fri, 22 Feb 2008 06:43:06 +0000 (UTC) (envelope-from freebsd@spatula.net) Received: from localhost (localhost.morons.org [127.0.0.1]) by turing.morons.org (Postfix) with ESMTP id 98739170DA; Thu, 21 Feb 2008 22:29:38 -0800 (PST) X-DomainKeys: Sendmail DomainKeys Filter v0.6.0 turing.morons.org 98739170DA DomainKey-Signature: a=rsa-sha1; s=selector1; d=spatula.net; c=nofws; q=dns; h=date:from:to:cc:subject:in-reply-to:message-id:references; b=RmPp8aMSXba/Cnw3yG+41lrSxWPMgw9ntsiaLClJyS+SCYOUqzZjIIlKQv+br5Jo+ crohJ7ix46V9tI0oDxg/SoycfYb2vuo4rtWT10C2bue6E17XnE9wAepGPEa49xIKBHK Z5VWYha+ovHwI02F9KGo5uHuVchEQI7E4ZMrDZ8= X-DKIM: Sendmail DKIM Filter v2.4.2 turing.morons.org 98739170DA DKIM-Signature: v=1; a=rsa-sha1; c=simple/simple; d=spatula.net; s=selector1; t=1203661778; bh=yoUYsiaP4/YaP71x+7V8QQfjF5Y=; h=X-Virus-Scanned:Date:From:X-X-Sender:To:cc:Subject:In-Reply-To: Message-ID:References:MIME-Version:Content-Type; b=KrYJ+0SbUfXIbcg AUGXKNTvSEoyVkCAVlHQ1mp785Qt0bHHdOoNohSwMX1NHL0sJv8CV9osxMyH/3GSX+I YpvnxNRYlzTz72gKiRj3+I4IH5ucGVkpEx1Wu8CWTvsxz6LMkpB5Q6D4VAqRtvEE1Of bwd9PE/vOhhlP22Tqw18qw= X-Virus-Scanned: amavisd-new at morons.org Received: from turing.morons.org ([127.0.0.1]) by localhost (turing.morons.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yuF92zAejNMa; Thu, 21 Feb 2008 22:29:37 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by turing.morons.org (Postfix) with ESMTP; Thu, 21 Feb 2008 22:29:37 -0800 (PST) Date: Thu, 21 Feb 2008 22:29:37 -0800 (PST) From: Nick Johnson X-X-Sender: spatula@turing To: Mika Nystrom In-Reply-To: <200802220549.m1M5nJhd085207@camembert.async.caltech.edu> Message-ID: <20080221222313.O2617@turing> References: <200802220549.m1M5nJhd085207@camembert.async.caltech.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-java@freebsd.org Subject: Re: Memory leak in 1.5.0 JVM X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Feb 2008 06:43:07 -0000 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/