• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can System.gc() call unreferenced()?

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, I have experimented on the Unreferenced interface. I realized that when my dummy test client disconnects, sometimes unreferenced() is called, but sometimes it doesn't. Even during the times when it doesn't, it gets called after 15 minutes due to the lease. However, the strange thing is that on the dummy test server, I ran a thread that calls System.gc() every 10 seconds. No matter what, the garbage collector never seem to call the unreferenced() method. Why? In the first place, is System.gc() the correct method to call?

Another thing, in my unreferenced() method, do I have to add in any cleanup codes like UnicastRemoteObject.unexport(this, true) or anything similar?
[ February 06, 2005: Message edited by: Liang Anmian ]
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You do realised that System.gc() is not guaranteed to actually do anything?
 
Liang Anmian
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops. How could I have forgotten about that? To think that my programmer exam was only last week.

So I guess there's no way to detect lost clients on the spot. It's ok. Not that big of a problem though.

Thanks for the reply anyway.
[ February 06, 2005: Message edited by: Liang Anmian ]
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Liang Anmian:
Oops. How could I have forgotten about that? To think that my programmer exam was only last week.

So I guess there's no way to detect lost clients on the spot. It's ok. Not that big of a problem though.

Thanks for the reply anyway.

[ February 06, 2005: Message edited by: Liang Anmian ]



When your client disconnects properly the Distributed Garbage Collection (rmi.dgc) tends to call unreferenced() almost immediately, but you should use some sort of disconnect method to guarantee that this happens. I tested it on W2K and dgc calls unreferenced almost immediately after I call disconnect and set the client DataProxy object to null. I haven't tested that on Solaris, but I suspect its the same since I'm running the Sun JRE on both.

I added connect and disconnect methods to the Data and DataProxy classes using a Session interface. This makes it easy to control session activity.
 
reply
    Bookmark Topic Watch Topic
  • New Topic