Reputation: 145
Is it still useful in VB.NET to assign objects to Nothing when finished using them, as mentioned here? Or has garbage collection improved to the point that this is no longer helpful/necessary?
Upvotes: 3
Views: 2778
Reputation: 24274
You are right, it's no longer needed except in a few corner-cases:
Upvotes: 1
Reputation: 7309
As the others said, it's not necessary in most cases.
If you are done using an object and want to claim its memory as soon as possible (for example, because it's a very big entity which contains many others), make it implement the Disposable pattern and use it via the Using directive.
In the particular case in which your big object does not reference any unmanaged resource, this is not fixing a memory leak, it's keeping your memory footprint small
Upvotes: 1
Reputation: 1038850
No, it's not useful in VB.NET. IIRC you should do this only if variables are pointing to dynamically created COM objects such as if you are doing Office Interop for example.
Upvotes: 1