473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help: Memory Management For My asp.net Managed Code!

VS2005
asp.net 2.0
C#
Developing with File System/Cassini instead of IIS (publish to IIS
every so often)

Hello guys,

I have a web app where I am using static variables on many pages to
maintain values between postbacks. I am also using several static
properties and methods on a class within my custom libraries (a .cs
file in the App_Code folder).

After constantly running the app while debugging (sometimes for three
or four hours straight,) my machine begins to slow to a crawl. I
ultimately receive a "System out of memory" message. The only program
being run on this machine during this time is Visual Studio 2005 w/my
web site (via the green triangle "Start Debugging" button) in the VS
IDE.

There is obviously some problem going on with memory management here.
Apparently I still need to destruct/destroy some objects manually,
since the .net garbage collector is not getting it.

Questions:

What am I doing wrong here?

How do I free the memory?

When I publish the site and run OUT of debug mode with IIS on the web
server, will it make any difference?

TIA

JP

Aug 3 '07 #1
7 1570
The solution is very simple: *do not* use static fields in a Page class to
attempt to maintain values between postbacks. Your alternatives are:
1) ViewState
2) Session
3) Hidden Form Fields
4) Cache
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"Joey" wrote:
VS2005
asp.net 2.0
C#
Developing with File System/Cassini instead of IIS (publish to IIS
every so often)

Hello guys,

I have a web app where I am using static variables on many pages to
maintain values between postbacks. I am also using several static
properties and methods on a class within my custom libraries (a .cs
file in the App_Code folder).

After constantly running the app while debugging (sometimes for three
or four hours straight,) my machine begins to slow to a crawl. I
ultimately receive a "System out of memory" message. The only program
being run on this machine during this time is Visual Studio 2005 w/my
web site (via the green triangle "Start Debugging" button) in the VS
IDE.

There is obviously some problem going on with memory management here.
Apparently I still need to destruct/destroy some objects manually,
since the .net garbage collector is not getting it.

Questions:

What am I doing wrong here?

How do I free the memory?

When I publish the site and run OUT of debug mode with IIS on the web
server, will it make any difference?

TIA

JP

Aug 3 '07 #2
On Aug 3, 3:54 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yohohhoandabottleofrum.comwrote :
The solution is very simple: *do not* use static fields in a Page class to
attempt to maintain values between postbacks. Your alternatives are:
1) ViewState
2) Session
3) Hidden Form Fields
4) Cache
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"Joey" wrote:
VS2005
asp.net 2.0
C#
Developing with File System/Cassini instead of IIS (publish to IIS
every so often)
Hello guys,
I have a web app where I am using static variables on many pages to
maintain values between postbacks. I am also using several static
properties and methods on a class within my custom libraries (a .cs
file in the App_Code folder).
After constantly running the app while debugging (sometimes for three
or four hours straight,) my machine begins to slow to a crawl. I
ultimately receive a "System out of memory" message. The only program
being run on this machine during this time is Visual Studio 2005 w/my
web site (via the green triangle "Start Debugging" button) in the VS
IDE.
There is obviously some problem going on with memory management here.
Apparently I still need to destruct/destroy some objects manually,
since the .net garbage collector is not getting it.
Questions:
What am I doing wrong here?
How do I free the memory?
When I publish the site and run OUT of debug mode with IIS on the web
server, will it make any difference?
TIA
JP- Hide quoted text -

- Show quoted text -
That will require a lot of recoding! Does anyone know of a way to
"destroy" the variables/free the memory with code?

Aug 6 '07 #3
Static variable should not be a problem. Although if you are using it on a
Page level then you most likely doing something wrong.
All users of the site will share that variable. So you can not use them to
maintain values between postbacks. Read up on "static" in C#.
-----------------------------------------------------------
Do you use a COM objects in your project? Like may be you doing MS Office
automation?
That can easily lead to memory leaks (without proper coding)

George.


"Joey" <jo*********@topscene.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.com...
On Aug 3, 3:54 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yohohhoandabottleofrum.comwrote :
>The solution is very simple: *do not* use static fields in a Page class
to
attempt to maintain values between postbacks. Your alternatives are:
1) ViewState
2) Session
3) Hidden Form Fields
4) Cache
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"Joey" wrote:
VS2005
asp.net 2.0
C#
Developing with File System/Cassini instead of IIS (publish to IIS
every so often)
Hello guys,
I have a web app where I am using static variables on many pages to
maintain values between postbacks. I am also using several static
properties and methods on a class within my custom libraries (a .cs
file in the App_Code folder).
After constantly running the app while debugging (sometimes for three
or four hours straight,) my machine begins to slow to a crawl. I
ultimately receive a "System out of memory" message. The only program
being run on this machine during this time is Visual Studio 2005 w/my
web site (via the green triangle "Start Debugging" button) in the VS
IDE.
There is obviously some problem going on with memory management here.
Apparently I still need to destruct/destroy some objects manually,
since the .net garbage collector is not getting it.
Questions:
What am I doing wrong here?
How do I free the memory?
When I publish the site and run OUT of debug mode with IIS on the web
server, will it make any difference?
TIA
JP- Hide quoted text -

- Show quoted text -

That will require a lot of recoding! Does anyone know of a way to
"destroy" the variables/free the memory with code?

Aug 6 '07 #4
On Aug 6, 11:53 am, "George Ter-Saakov" <gt-...@cardone.comwrote:
Static variable should not be a problem. Although if you are using it on a
Page level then you most likely doing something wrong.
All users of the site will share that variable. So you can not use them to
maintain values between postbacks. Read up on "static" in C#.
Whoa! The static variables are members of the page class. I thought
different page objects were being instatiated with each page view. Is
this not true?

Aug 6 '07 #5
On Aug 6, 12:05 pm, Joey <joey.pow...@topscene.comwrote:
On Aug 6, 11:53 am, "George Ter-Saakov" <gt-...@cardone.comwrote:
Static variable should not be a problem. Although if you are using it on a
Page level then you most likely doing something wrong.
All users of the site will share that variable. So you can not use them to
maintain values between postbacks. Read up on "static" in C#.

Whoa! The static variables are members of the page class. I thought
different page objects were being instatiated with each page view. Is
this not true?
Okay Okay I think I get it. Since they are static, they are not
instantiated in the first place! Right?

Aug 6 '07 #6
You got it.
Think of static variables as of "global variables"

George

"Joey" <jo*********@topscene.comwrote in message
news:11**********************@r34g2000hsd.googlegr oups.com...
On Aug 6, 12:05 pm, Joey <joey.pow...@topscene.comwrote:
>On Aug 6, 11:53 am, "George Ter-Saakov" <gt-...@cardone.comwrote:
Static variable should not be a problem. Although if you are using it
on a
Page level then you most likely doing something wrong.
All users of the site will share that variable. So you can not use them
to
maintain values between postbacks. Read up on "static" in C#.

Whoa! The static variables are members of the page class. I thought
different page objects were being instatiated with each page view. Is
this not true?

Okay Okay I think I get it. Since they are static, they are not
instantiated in the first place! Right?

Aug 6 '07 #7
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:O8**************@TK2MSFTNGP03.phx.gbl...
Think of static variables as of "global variables"
Yes indeed. Static variables need *very* careful management in ASP.NET...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 6 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Richard Jones | last post by:
Garbage Collection & Memory Management Summer School 20-21 July 2004, Canterbury, UK The performance of today's memory-hungry applications depends on efficient dynamic memory management,...
0
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since...
5
by: Scott Dowd | last post by:
I need explicit example of how to use SetupDi* functions in both C# .NET and VB .NET to determine device interface detail for a given device class with interface information detail. All examples...
2
by: Aravind | last post by:
Unable to consume Process reserved memory Hi , This is a Windows form application which interacts with the unmanaged C++ codes . In unmanaged c++ code we allocate around 130MB on the heap for...
7
by: Casey Leamon | last post by:
I've been noticing that all of my .NET apps seem to progressivly use more and more memory. Even after several reworks of the code I can only manage to slow the growth. Is there some Garbage...
35
by: MuZZy | last post by:
Hi All, I got a issue here and hope someone can help me: Let's consider this code: // =================== CODE START ================================= using System; using System.Data; ...
3
by: Aravindakumar Venugopalan | last post by:
Hi , A Windows form application which interacting with the unmanaged C++ codes . In unmanaged c++ code we allocate around 130MB on the heap for annalysing high resolution images . Earlier...
2
by: Epetruk | last post by:
Hello, I have a problem where an application I am working on throws an OutOfMemoryException when I run it in Release mode, whereas it doesn't do this when I am running in Debug. The...
5
by: Max2006 | last post by:
Hi, What is the limit for memory that a .NET process or AppDomain can use? Thank you, Max
17
by: Cesar | last post by:
Hello people. I'm having a Winform app that contains a webbrowser control that keeps navigating from one page to another permanentrly to make some tests. The problem I'm having is that after a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.