Loops and Garbage Collection

后端 未结 5 1937
鱼传尺愫
鱼传尺愫 2021-01-13 13:31

I am working on a web application and I have run into the following situation.

Dim a as Object
Dim i as Integer = 0

Try

    For i=1 to 5

        a = new O         


        
5条回答
  •  暖寄归人
    2021-01-13 14:15

    Like everyone stated above you do not need to explicitly set your variables to nothing, as it is handled automatically. However, if for whatever reason you want to force the GC to collect, you can run this:

    System.GC.Collect()
    

提交回复
热议问题