you have to manually release all com objects when you are done with them,
otherwise you are waiting for the gc to do it, which it may ignored for a
long time because the allocations (managed) are so small.
see
System.Runtime.InteropServices.Marshal.ReleaseComObject
this should be called when you are done with a com object (it will decrement
the reference counter in the com object and allow the com object to release
its resources).
-- bruce (sqlwork.com)
> Hi All,
>
[quoted text clipped - 16 lines]
> Thanking in advance for any help,
> Chetan Raj
Chetan Raj - 14 Aug 2004 08:00 GMT
We create a pool of 20-40 instances of the COM object and reuse these
instances for all the tasks. We are never done with them!
Thanks,
Chetan
> you have to manually release all com objects when you are done with them,
> otherwise you are waiting for the gc to do it, which it may ignored for a
[quoted text clipped - 9 lines]
>
> -- bruce (sqlwork.com)
Chetan Raj - 15 Aug 2004 09:09 GMT
Hi All,
We tried System.Runtime.InteropServices.Marshal.ReleaseComObject,
but that did not help.
aspnet_wp.exe still allocates unmanaged memory and it recyles when it
reaches 60% of total memory.
Whats causing aspnet_wp.exe to allocate so much unmanaged memory and
then recycle eventually?
Thanks in advance for any help,
Chetan Raj
> > you have to manually release all com objects when you are done with them,
> > otherwise you are waiting for the gc to do it, which it may ignored for a
[quoted text clipped - 9 lines]
> >
> > -- bruce (sqlwork.com)
Stephen Woolhead - 15 Aug 2004 06:43 GMT
There is a AddMemoryPressure function off the GC that allows you to tell the
GC that your small managed allocation is looking after a much bigger
unmanaged allocation, and that it should pay more attention to cleaning it
up, it's used something like this
class LargeUnmanagedContainer
{
private long _size;
LargeUnmanagedContainer ()
{
// Allocate a lot of unmanaged memory and
// set _size to the amout of memory used
GC.AddMemoryPressure(_size);
// other work
}
~LargeUnmanagedContainer()
{
GC.RemoveMemoryPressure(_size);
// other work
}
}
Never used it, remember it from a talk I was at several months ago, might
help force the GC to do some clean up for you.
Stephen.
> you have to manually release all com objects when you are done with them,
> otherwise you are waiting for the gc to do it, which it may ignored for a
[quoted text clipped - 32 lines]
>> Thanking in advance for any help,
>> Chetan Raj
Chetan Raj - 16 Aug 2004 05:50 GMT
hi,
We ran the unmanaged code out of aspnet_wp.exe process by making it a
COM+ Service. The unmanaged code ran under DllHost.exe process. Even
then aspnet_wp.exe unmamged memory was increasing at higher rate. I
looked at the modules within aspnet_wp.exe process and made sure that
it does not contain any of our unmanged module within it.
Can any one explain this?
Thanks,
Chetan Raj
> There is a AddMemoryPressure function off the GC that allows you to tell the
> GC that your small managed allocation is looking after a much bigger
[quoted text clipped - 25 lines]
>
> Stephen.
i think gc.waitforpendingfinalizers() may help in this scenario.
> Hi All,
>
[quoted text clipped - 16 lines]
> Thanking in advance for any help,
> Chetan Raj