Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Basic garbage collection

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?

like image 235
NathanX Avatar asked Jun 12 '26 16:06

NathanX


1 Answers

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

like image 163
dario_ramos Avatar answered Jun 14 '26 06:06

dario_ramos