On Aug 3, 3:54 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yohohhoandabottleofrum.com> wrote:
> The solution is very simple: *do not* use static fields in a Page class to
> attempt to maintain values between postbacks. Your alternatives are:
[quoted text clipped - 46 lines]
>
> - 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?
George Ter-Saakov - 06 Aug 2007 17:53 GMT
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.
> On Aug 3, 3:54 pm, Peter Bromberg [C# MVP]
> <pbromb...@yahoo.yohohhoandabottleofrum.com> wrote:
[quoted text clipped - 52 lines]
> That will require a lot of recoding! Does anyone know of a way to
> "destroy" the variables/free the memory with code?
Joey - 06 Aug 2007 18:05 GMT
> 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?
Joey - 06 Aug 2007 18:07 GMT
> > Static variable should not be a problem. Although if you are using it on a
> > Page level then you most likely doing something wrong.
[quoted text clipped - 4 lines]
> 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?
George Ter-Saakov - 06 Aug 2007 18:29 GMT
You got it.
Think of static variables as of "global variables"
George
>> > Static variable should not be a problem. Although if you are using it
>> > on a
[quoted text clipped - 9 lines]
> Okay Okay I think I get it. Since they are static, they are not
> instantiated in the first place! Right?
Mark Rae [MVP] - 06 Aug 2007 18:35 GMT
> Think of static variables as of "global variables"
Yes indeed. Static variables need *very* careful management in ASP.NET...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net