The Artima Developer Community
Sponsored Link

Java Buzz Forum
Leaning on the Crutch Once More: Detecting GC'd Objects

0 replies on 1 page.

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 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
Leaning on the Crutch Once More: Detecting GC'd Objects Posted: Jun 21, 2004 5:21 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: Leaning on the Crutch Once More: Detecting GC'd Objects
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

Leo Simons challenged me a while back to do super-clean object pooling via aspects. I couldn't quite get it, but I tried. I fired up Þe old IDEA and got a step closer today. Still haven't gotten around the new function declaring a type for its return value yet,though. I mean, you call new Foo() and expect an actual instance of Foo. How unreasonable is that? But I digress.

The ReleaseManager class returns a proxy implementing all the interfaces of a class, and allows for the detection and registration of callbacks (which receive the real instance) for when the proxy falls out of scope. Nothing fancy here, most (good) pooled DataSource implementations do this now for Connection instances they loan out.

The fun part is applying an aspect to capture and do this for you to provide "transparent pooling". There is still a problem of needing a GC to force return to the pool. Additionally, you cannot capture on public Mammal+.new(..) and return anything other than a correct instance of the class being newed (maybe you could return a subclass, which opens up the possibility of cglib proxies, but that has heavy-object ramifications).

I'm still thinking about it, Leo, and I am exceptionally stubborn =)

Read: Leaning on the Crutch Once More: Detecting GC'd Objects

Topic: ADF faces Previous Topic   Next Topic Topic: Choosing Your Seat at a Meeting

Sponsored Links



Google
  Web Artima.com   

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