Self killing object in VB.NET?

  • Thread starter Thread starter vinh79
  • Start date Start date
V

vinh79

Hi all,

I have a scenario that I need to create a global object to pass as a
parameter to a thread(since you cannot pass parameters directly to
threads).

After I'm done with the thread, it exits, but how do I kill the global
object that I have just created, as it is eating away memory.

Thanks all!
vber
 
After I'm done with the thread, it exits, but how do I kill the global
object that I have just created, as it is eating away memory.

The garbage collector will free the object from memory some time after you
no longer hold any references to it. In the garbage collected world of .NET
you don't explicitly "kill" objects.


Mattias
 
I have a scenario that I need to create a global object to pass as a
parameter to a thread(since you cannot pass parameters directly to
threads).

After I'm done with the thread, it exits, but how do I kill the global
object that I have just created, as it is eating away memory.

Remove references to the object. Then the GC will destroy it after some
time. If the object uses unmanaged resources, for example, you could
implement the 'IDisposable' interface (see documentation).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top