From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6287 invoked by alias); 27 Jul 2009 14:43:42 -0000 Received: (qmail 6277 invoked by uid 22791); 27 Jul 2009 14:43:41 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_46,SPF_PASS X-Spam-Check-By: sourceware.org Received: from blu0-omc3-s16.blu0.hotmail.com (HELO blu0-omc3-s16.blu0.hotmail.com) (65.55.116.91) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Jul 2009 14:43:31 +0000 Received: from BLU0-SMTP83 ([65.55.116.72]) by blu0-omc3-s16.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 27 Jul 2009 07:43:29 -0700 Message-ID: Received: from gammaxp64a ([174.18.208.144]) by BLU0-SMTP83.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 27 Jul 2009 07:43:28 -0700 From: "BGB" To: "Andrew Haley" , "abhishek desai" Cc: References: <898285d30907270241h2a5a74abu8ae9a849399b8192@mail.gmail.com> <4A6D7C57.6080902@redhat.com> Subject: Re: Calling the garbage collector. Date: Mon, 27 Jul 2009 14:43:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00072.txt.bz2 ----- Original Message ----- From: "Andrew Haley" To: "abhishek desai" Cc: Sent: Monday, July 27, 2009 3:07 AM Subject: Re: Calling the garbage collector. > On 07/27/2009 11:41 AM, abhishek desai wrote: >> Hi, >> >> I have a simple java program to test the garbage collection. It has >> the two java files shown below. >> >> TestClass.java >> >> public class TestClass { >> protected void finalize() throws Throwable { >> System.out.println("Java TestClass finalizer called."); >> } >> } >> >> >> HelloWorld.java >> >> import TestClass; >> >> class HelloWorld >> { >> public static void main(String args[]) { >> System.out.println("HelloWorld\n"); >> >> TestClass a = new TestClass(); >> a = null; >> System.gc(); >> } >> } >> >> >> When I compile this using javac to a class file and run the bytecode >> using the 'java' interpreter, the finalize funtion for TestClass.java >> is called. >> When I compile the same set of files using gcj to machine code, the >> finalizer is not called. Can any one tell me why this happens and what >> I will have to do to get the finalizer called when object is no longer >> used. > > The finalize will be called when the object is collected. When the > object actually gets collected is not defined, and is not guaranteed > to happen before the program exits. Also, there is no absolute > guarantee that the object will ever be collected. > hmm... maybe Java needs 'delete'?... > Andrew. >