Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Memory Usage and Garbage Collection

Reply
Thread Tools

Memory Usage and Garbage Collection

 
 
Andy
Guest
Posts: n/a
 
      03-03-2004
Along with many others I've noticed the large amount of memory that
can be taken up by the aspnet_wp.exe. I've found that I can better
control and limit this memory consumption by including a GC.Collect()
in the Application_EndRequest() event handler in the Global.asax file.

Whilst this appears to help my memory consumption issues I've also
read that forced GC.Collect() can be inefficient.

Assuming that I don't see any adverse effects on performance - which I
haven't yet, but early days in the testing - does anybody know of any
reasons why I shouldn't adopt this approach?

Thanks
Andy
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      03-03-2004
I think you should be asking if anybody knows of any reasons why you SHOULD
adopt this approach. The default is to let the Framework manage your memory
for you, and defaults are defaults for a reason. Unless it's causing a
problem, I would let the Framework do what is designed to do best.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Andy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Along with many others I've noticed the large amount of memory that
> can be taken up by the aspnet_wp.exe. I've found that I can better
> control and limit this memory consumption by including a GC.Collect()
> in the Application_EndRequest() event handler in the Global.asax file.
>
> Whilst this appears to help my memory consumption issues I've also
> read that forced GC.Collect() can be inefficient.
>
> Assuming that I don't see any adverse effects on performance - which I
> haven't yet, but early days in the testing - does anybody know of any
> reasons why I shouldn't adopt this approach?
>
> Thanks
> Andy



 
Reply With Quote
 
 
 
 
Eric Lawrence [MSFT]
Guest
Posts: n/a
 
      03-04-2004
Agreed.

That said, a deveoper should of course review the ASPX pages and try to
minimize the memory consumption; converting from strings to stringbuilders
where necessary, etc.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.


"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I think you should be asking if anybody knows of any reasons why you

SHOULD
> adopt this approach. The default is to let the Framework manage your

memory
> for you, and defaults are defaults for a reason. Unless it's causing a
> problem, I would let the Framework do what is designed to do best.
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Andy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > Along with many others I've noticed the large amount of memory that
> > can be taken up by the aspnet_wp.exe. I've found that I can better
> > control and limit this memory consumption by including a GC.Collect()
> > in the Application_EndRequest() event handler in the Global.asax file.
> >
> > Whilst this appears to help my memory consumption issues I've also
> > read that forced GC.Collect() can be inefficient.
> >
> > Assuming that I don't see any adverse effects on performance - which I
> > haven't yet, but early days in the testing - does anybody know of any
> > reasons why I shouldn't adopt this approach?
> >
> > Thanks
> > Andy

>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      03-04-2004
Thanks a lot for Kevin and Eric's suggestions.

Hi Andy,

As Kevin and Eric have mentioned, generally the dotnet clr will
automatically control the memory management. The "System.GC.Collect" will
force the clr to execute collection, but System.GC.Collect() is used for
demonstration purposes, not as a recommended procedure. Explicitly calling
GC.Collect() changes the GC's autotuning capabilities. Repeatedly calling
GC.Collect() suspends all threads until the collection completes. This
could greatly impede performance. And here is the reference on "Forcing
Garbage Collection" in MSDN:

#Forcing a Garbage Collection
http://msdn.microsoft.com/library/en...cingcollection.
asp?frame=true

And you may also view the following reference in MSDN for more detailed
description on Garbage Collection in DOTNET:
#Programming for Garbage Collection
http://msdn.microsoft.com/library/en...rammingessenti
alsforgarbagecollection.asp?frame=true

Further more, as you mentioned the performance in ASP.NET, below are some
tech articles discussing on it:

#ASP.NET Performance Monitoring, and When to Alert Administrators
http://msdn.microsoft.com/library/en...rf.asp?frame=t
rue

#Production Debugging for .NET Framework Applications
http://msdn.microsoft.com/library/en...asp?frame=true

Hope these help.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      03-04-2004
Hi Guys,

Thanks very much for the advice - I'll revert to letting the GC take
responsibility. Given that memory consumption on the aspnet_wp seems
so variable are there any articles or guidelines indicating what
represents normal operation and what might indicate a design or coding
problem?

My project makes extensive use of the 'Cache' for storing sections of
dynamic pages and I'm a little bit concerned about the scalability of
this approach, particularly with regards to memory consumption, but
I'm finding it difficult to get a clear indication of how memory
requirements of the Cache are varying.

Thanks,
Andy

http://www.velocityreviews.com/forums/(E-Mail Removed) (Steven Cheng[MSFT]) wrote in message news:<(E-Mail Removed)>...
> Thanks a lot for Kevin and Eric's suggestions.
>
> Hi Andy,
>
> As Kevin and Eric have mentioned, generally the dotnet clr will
> automatically control the memory management. The "System.GC.Collect" will
> force the clr to execute collection, but System.GC.Collect() is used for
> demonstration purposes, not as a recommended procedure. Explicitly calling
> GC.Collect() changes the GC's autotuning capabilities. Repeatedly calling
> GC.Collect() suspends all threads until the collection completes. This
> could greatly impede performance. And here is the reference on "Forcing
> Garbage Collection" in MSDN:
>
> #Forcing a Garbage Collection
> http://msdn.microsoft.com/library/en...cingcollection.
> asp?frame=true
>
> And you may also view the following reference in MSDN for more detailed
> description on Garbage Collection in DOTNET:
> #Programming for Garbage Collection
> http://msdn.microsoft.com/library/en...rammingessenti
> alsforgarbagecollection.asp?frame=true
>
> Further more, as you mentioned the performance in ASP.NET, below are some
> tech articles discussing on it:
>
> #ASP.NET Performance Monitoring, and When to Alert Administrators
> http://msdn.microsoft.com/library/en...rf.asp?frame=t
> rue
>
> #Production Debugging for .NET Framework Applications
> http://msdn.microsoft.com/library/en...asp?frame=true
>
> Hope these help.
>
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      03-04-2004
Hi Andy,

Thanks for your response. I think the following tech articles may help you
on designing high-performance WEB application and how to properly control
memory management:

#Developing High-Performance ASP.NET Applications
http://msdn.microsoft.com/library/en...lopinghigh-per
formanceaspnetapplications.asp?frame=true

#Am I Losing My Memory?
http://msdn.microsoft.com/library/en...72002.asp?fram
e=true

#Performance Counters for ASP.NET
http://msdn.microsoft.com/library/en...ormanceCounter
sForASPNET.asp?frame=true

#ASP.NET Performance Monitoring, and When to Alert Administrators
http://msdn.microsoft.com/library/en...rf.asp?frame=t
rue

#Production Debugging for .NET Framework Applications
http://msdn.microsoft.com/library/en...asp?frame=true

#ASP.NET Caching Features
http://msdn.microsoft.com/library/en...achingfeatures
..asp?frame=true


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      03-05-2004
Hi Steven,

Thanks for your reply - following your earlier response I worked
through the articles you directed me to and feel that I am now making
progress and starting to get a handle on how to memory management
works - and now I have plenty more reading to do!

Thanks again,
Andy

(E-Mail Removed) (Steven Cheng[MSFT]) wrote in message news:<(E-Mail Removed)>...
> Hi Andy,
>
> Thanks for your response. I think the following tech articles may help you
> on designing high-performance WEB application and how to properly control
> memory management:
>
> #Developing High-Performance ASP.NET Applications
> http://msdn.microsoft.com/library/en...lopinghigh-per
> formanceaspnetapplications.asp?frame=true
>
> #Am I Losing My Memory?
> http://msdn.microsoft.com/library/en...72002.asp?fram
> e=true
>
> #Performance Counters for ASP.NET
> http://msdn.microsoft.com/library/en...ormanceCounter
> sForASPNET.asp?frame=true
>
> #ASP.NET Performance Monitoring, and When to Alert Administrators
> http://msdn.microsoft.com/library/en...rf.asp?frame=t
> rue
>
> #Production Debugging for .NET Framework Applications
> http://msdn.microsoft.com/library/en...asp?frame=true
>
> #ASP.NET Caching Features
> http://msdn.microsoft.com/library/en...achingfeatures
> .asp?frame=true
>
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Manual Memory Management and Automatic Garbage Collection Tridib Bandopadhyay Ruby 25 05-19-2011 11:50 PM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
Checking for Memory Leaks and Garbage Collection Tom Cole Javascript 1 03-10-2007 03:29 AM
[ruby-gtk2] Garbage collection and memory use David Espada Ruby 1 01-18-2005 04:52 PM
Summer School on Garbage Collection & Memory Management Richard Jones C++ 0 04-29-2004 04:02 PM



Advertisments