|
-
Apr 17th, 2002, 02:19 PM
#1
Thread Starter
Dazed Member
Suppressing Finializers?
Does anyone if this can be done in Java? I have some resources that need to be cleaned up in a timely fashion and im having issues with the lag between when the object is no longer refrenced by the application and when the object is consumed by the GC. Ive been working with Visual Basic Net lately and ive found a way to suppress them.
Code:
Class Demo
Private m_disposed As Boolean
Public Sub Disposed()
If(Not m_disposed) Then
Finialize()
GC.SuppressFinialize(this)
m_disposed = True
End If
End Sub
Protected Overides Sub Finialize()
'perform any necessary clean up here
End Sub
End Class
Last edited by Dilenger4; Apr 17th, 2002 at 03:13 PM.
-
Apr 17th, 2002, 02:51 PM
#2
Maybe I don't understand correctly, but why can't you just call the System's gc() method to run the garbage collector?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Apr 17th, 2002, 03:13 PM
#3
Thread Starter
Dazed Member
I thought about that, but i wasn't to sure if i wanted to explictly run the GC in order to clean up a small amount of memory. I was thinking that the application might incur a performance hit by explictly invoking the GC rather than calling the finalize method directly. Im still not quite sure why VB.Net has a way to suppress finializers since if the finialize method is called and memory is reclaimed the method should only be invoked once.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|