From: "BGB" <cr88192@hotmail.com>
To: "Andrew Haley" <aph@redhat.com>, "abhishek desai" <abhi00@gmail.com>
Cc: <java@gcc.gnu.org>
Subject: Re: Calling the garbage collector.
Date: Mon, 27 Jul 2009 14:43:00 -0000 [thread overview]
Message-ID: <BLU0-SMTP837D7B13A3D09975F3FBD5E4140@phx.gbl> (raw)
In-Reply-To: <4A6D7C57.6080902@redhat.com>
----- Original Message -----
From: "Andrew Haley" <aph@redhat.com>
To: "abhishek desai" <abhi00@gmail.com>
Cc: <java@gcc.gnu.org>
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.
>
next prev parent reply other threads:[~2009-07-27 14:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-27 9:41 abhishek desai
2009-07-27 10:07 ` Andrew Haley
2009-07-27 14:43 ` BGB [this message]
2009-07-27 15:37 Chris Gray
2009-07-27 16:16 ` BGB
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BLU0-SMTP837D7B13A3D09975F3FBD5E4140@phx.gbl \
--to=cr88192@hotmail.com \
--cc=abhi00@gmail.com \
--cc=aph@redhat.com \
--cc=java@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).