The Artima Developer Community
Sponsored Link

Java Answers Forum
Garbage collector

6 replies on 1 page. Most recent reply: Jan 21, 2005 1:53 AM by JavaAdd Ict

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
Parag

Posts: 4
Nickname: ksparag
Registered: Nov, 2004

Garbage collector Posted: Nov 29, 2004 1:43 AM
Reply to this message Reply
Advertisement
Why cant we force garbage collector to execute? Why Java creators have left it upto the scheduler to execute when to execute garbage collector thread?


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Garbage collector Posted: Dec 17, 2004 3:36 AM
Reply to this message Reply
Who said so?

System.gc();


public static void gc()

Runs the garbage collector.

Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects. The call System.gc() is effectively equivalent to the call:

See Also:Runtime.gc()

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Garbage collector Posted: Dec 20, 2004 12:43 AM
Reply to this message Reply
System.gc() does not force the garbage collector to start. It just sends a garbage collector request.
Let's say the gc get's a higher priority for the next call (it's not entirely true, but it describes it well enough).

It often happens that the gc get's called allmost at the same moment after you callSystem.gc(), but not allways.

Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: Garbage collector Posted: Dec 20, 2004 11:56 PM
Reply to this message Reply
Garbage collection is not a mandatory part of a JVM. It is entirely possible to ship compliant JVMs that do not have any garbage collection facility.

If I remember correctly, one of the earlier Microsoft JVMs did not do this and did not suffer for it. In fact it was one of the fastest ones around at the time.

Vince.

Chris Miller

Posts: 23
Nickname: lordsauron
Registered: Jan, 2005

Re: Garbage collector Posted: Jan 19, 2005 5:29 PM
Reply to this message Reply
Why? With computers having as much memory as they do now, why would you want to activate the
gc
. If you properly spread your program out into processes, then you can kill the process when you're done with it. After that the
gc
should kill the memory it was using normally. You must be running a huge program to need that, however.

Chris Miller

Posts: 23
Nickname: lordsauron
Registered: Jan, 2005

Re: Garbage collector Posted: Jan 19, 2005 5:30 PM
Reply to this message Reply
Oops... sorry about the weirdo formatting... Well, we learn new things every day... I learned exactly what the java formatting tag does.

JavaAdd Ict

Posts: 5
Nickname: javaaddict
Registered: May, 2004

Re: Garbage collector Posted: Jan 21, 2005 1:53 AM
Reply to this message Reply
Its true that System.gc() is still a request for JVM. Its then upto the JVM whether to run GC thread or not.

Following link gives some detailed info on GC with VMs
http://java.sun.com/docs/hotspot/gc1.4.2/

Flat View: This topic has 6 replies on 1 page
Topic: Can't select all text Previous Topic   Next Topic Topic: Is there a Visual GUI editor ?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use