Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Controlling the Garbage Collector Date: Mon, 25 Jun 2012 20:41:48 +0200 Lines: 48 Message-ID: References: <6KSdnTwztJvtR0bSnZ2dnUVZ_t-dnZ2d@giganews.com> <_JmdnUu_Z-scJEHSnZ2dnUVZ_t6dnZ2d@giganews.com> <4fe27687$0$281$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net v8j/D88nLw8GOgew4cmADghzgzyrhtbOiVyXrQjERpgrIOaNawywV2FlhR0HPccFs= Cancel-Lock: sha1:0vZ3SS9ZrR7QSTyhtKyyrRjSiiQ= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:15584 On 25.06.2012 19:45, Eric Sosman wrote: > On 6/25/2012 1:01 PM, Andreas Leitgeb wrote: >> Maybe slightly more interesting questions: >> What would be the behaviour of that proposed call, >> - if "old" *is* still (hard-)referenced from live objects? >> - if there's still a weak/soft-reference on that object? >> (pick one: Exception, force(for weak/soft-refs) or ignore?) > > Exactly: The JVM could not simply trust the System.gc(obj) > call to be telling the truth, because that would open the door > to all manner of attacks. Not just attacks but simple errors as well. > Therefore the JVM would have to verify > that obj was unreachable (at whatever strength) before deciding > to dispose of it. That is, the JVM would have to run nearly all > of the garbage collector to determine obj's reachability -- so > why not just run the ordinary GC in the ordinary way? I'm at a > loss to imagine what benefit a System.gc(obj) would offer. I had exactly this kind of reasoning in mind when I said: > I once mused about such a thing as well. If you think a bit longer > about this then you'll notice that it won't work: these objects still > have to be visited because they may have references to other objects > not in the uncollectable space. You'll probably do not gain much - > if anything at all. Thank you for the elaboration, Eric and Andreas! I think a non uniform object memory model (e.g. some GCed, some manually managed) cannot get rid of the GC overhead even for the manual kind as long as it is allowed to have references between the different kinds of objects. Disallowing that however would make the distinction visible and you end up with a language with a non uniform object model. That would certainly make programmers' lives harder instead of easier. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/