Piotrekk,
You should only release the unmanaged handles, or decrement the
reference count on the COM object that you are holding when you are done
with it. The wrapper for a COM object will still be in memory (which should
be light), but the COM object itself should be disposed of at that point.
You shouldn't have to call Collect at all, rather, you should be letting
the CLR collect garbage for you.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Piotrekk" <Pi*************@gmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
But there is one problem with ReleaseComObject. It will not release
the memory in a second. When I am finished with COM object and pass it
to ReleaseComObject I am done with the pointer. But the memory will
not be released immediately.
Or maybe I am wrong and memory will be released in a moment?
I am in need of releasing memory right after I stop using COM. When
using few 500 mb resources I really shouldn't wait for GC to collect
it...
As it is written in link i gave you ( MyResource inheriting from
IDisposable ) calling Dispose method should release memory by calling
API function private extern static Boolean CloseHandle(IntPtr handle);
- i haven't tried that yet.
Right now I am a bit confused if ReleaseComObject will release the
memory immidiately.