Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / December 2004

Tip: Looking for answers? Try searching our database.

ASP.NET UnManaged Memory Shoots Up,

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chetan Raj - 13 Aug 2004 09:59 GMT
Hi All,

We have a web-application in asp.net that interacts with legacy code
written in COM. The memory usage in aspnet_wp.exe increases every sec
and never reduces. Using the .NET performance counters, we found that
unmanaged memory was 90% of the total private bytes of aspnet_wp.exe.

We suspected that the COM code has memory leaks. So we made it as a
COM+ Service running as dllhost.exe. Surprisingly, there was no memory
increase in the DllHost.exe of this COM service, but aspnet_wp.exe's
memory was still shooting up. Again thru Performance counters we found
that unmanaged memory was taking around 80% of the total private bytes
of aspnet_wp.exe.

Now, can anyone help us in knowing the cause for the memory shoot up?
How to detect, which part of the code is responsible for the memory
increase? And what is holding on to the memory?

Thanking in advance for any help,
Chetan Raj
bruce barker - 13 Aug 2004 18:17 GMT
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.
samik - 22 Dec 2004 08:39 GMT
i think gc.waitforpendingfinalizers() may help in this scenario.

> Hi All,
>
[quoted text clipped - 16 lines]
> Thanking in advance for any help,
> Chetan Raj

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.