views:

17

answers:

1

Hi All,

I am combating some memory issues in my app and am finally managing to get to the bottom of it. I have had an example recently where my process memory went up to 800mb when processing a task. I have managed to get this to settle at 140mb now which is perfectly acceptable. However this has made me question my understanding of the .NET Garbage Collector. My memory issue was fixed by freeing 2 non .NET objects (TADOCommand and TDataSet - in delphi) after every use. The scope of these variables are local to the procedure so I presumed they should be cleared up automagically because nothing should have a reference to them.

So, how does .NET handle freeing objects that are not .NET? Or doesn't it?

Thanks.

+3  A: 

It doesn't. The .NET Garbage Collector only handles managed objects. Everything else must be cleaned up by something else.

If said resources are encapsulated by managed types, you can use IDisposable to implement the cleanup.

Brian Rasmussen
Ok, that's what I thought after finding the cause to my issue.Thanks.
webnoob