Results 1 to 3 of 3

Thread: Suppressing Finializers?

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    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.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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
  •  



Click Here to Expand Forum to Full Width