Does the .dispose() method do anything at all?

前端 未结 4 1894
鱼传尺愫
鱼传尺愫 2021-02-09 20:32

I was experimenting with ways to get rid of some memory leaks within my application the other day when I realized that I know virtually nothing about cleaning up my resources.

4条回答
  •  礼貌的吻别
    2021-02-09 21:18

    I'm going to point out something here that hasn't been explicitly mentioned: calling Dispose() will only clean up (free) unmanaged resources if the developer of the component has coded it.

    What I mean is this: if you suspect you have a memory leak, calling Dispose() is not going to fix it if the original developer has done a lousy job and not correctly freed up unmanaged resources. For a bit more info, check this blog post. Take note of the statement The behaviour of Dispose is defined by the developer.

提交回复
热议问题