If I have something like this within a sub/function:
Dim a as new myclass
Does this leave a memory leak if I am constantly calling this function creating new instances of this class? Do I have to destroy it or something when I am done using it?
Printable View
If I have something like this within a sub/function:
Dim a as new myclass
Does this leave a memory leak if I am constantly calling this function creating new instances of this class? Do I have to destroy it or something when I am done using it?
Read this article to learn a bit about how memory management in .NET works.
When the Sub/Function completes, the run-time engine knows that the variable you created is no longer going to be used. The Garbage Collector will eventually reclaim the memory pointed to by that local variable.
No, a memory leak is not created in this case.