I understand that static variables have app-domain scope. Till the app-domain
is in memory, the static variable will be in memory. When are the app-domains
unloaded is the question. I have read somewhere in this forum that statics
live till the asp.net process is recycled. Please clarify if someone can.
Thanx!
"David Jessee" wrote: I'd be VERY careful about using a shared page member for state management. its true that there is only that single value for all instances of that type, but there is no way of knowing what the context of that value is doing. E.g. I set PageX.StaticValue1...its value is retained unless there are no longer any instances of PageX in the application's memory. "Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... I am well aware of state management techniques like Session, Application, View State, Cookies, etc.. However, I recently discovered that a static field (variable) essentially acts like an Application variable. If you set the value of a static field on one page of your ASP.NET application, it is suddenly avaiable to every session.
Are there any general guidelines for using this technique? I don't recall ANY mention of this in training, or documentation online regarding options for maintaining state.
Thanks in advance. Mark
4 1937
The ASP.Net worker process can be recycled under a number of scenarios. You
can control these normal scenarios by going to:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFI G
(c:\winnt on 2000 and framework version might be different) and opening
machine.config (don't mess around in there!). Find "processModel
Attributes" and you'll find documentation describing a number of settings -
some of which are used for controlling when the worker process is recycled.
In IIS 6.0, there's an ASP.net tab which controls much of these things
(maybe even all,dont' remember).
basically the worker process can recycle itself at certain times/intervals,
when the memory reaches a certain amount, after being idle for too long and
so on. The worker process also terminates when IIS is restarted, or the
web.config file touched
Of course, the worker process can abnormally termniate...like if the system
crashed ;) or some cltr-alt-deletes the process...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.com... I understand that static variables have app-domain scope. Till the
app-domain is in memory, the static variable will be in memory. When are the
app-domains unloaded is the question. I have read somewhere in this forum that statics live till the asp.net process is recycled. Please clarify if someone can. Thanx!
"David Jessee" wrote:
I'd be VERY careful about using a shared page member for state
management. its true that there is only that single value for all instances of that type, but there is no way of knowing what the context of that value is doing. E.g. I set PageX.StaticValue1...its value is retained unless
there are no longer any instances of PageX in the application's memory. "Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... I am well aware of state management techniques like Session,
Application, View State, Cookies, etc.. However, I recently discovered that a
static field (variable) essentially acts like an Application variable. If
you set the value of a static field on one page of your ASP.NET application,
it is suddenly avaiable to every session.
Are there any general guidelines for using this technique? I don't
recall ANY mention of this in training, or documentation online regarding
options for maintaining state.
Thanks in advance. Mark
Karl,
I undertand that. My question was more to do with the lifespan of a "static"
variable. When does the statc variable really becomes unreachable?
"Karl Seguin" wrote: The ASP.Net worker process can be recycled under a number of scenarios. You can control these normal scenarios by going to:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFI G
(c:\winnt on 2000 and framework version might be different) and opening machine.config (don't mess around in there!). Find "processModel Attributes" and you'll find documentation describing a number of settings - some of which are used for controlling when the worker process is recycled. In IIS 6.0, there's an ASP.net tab which controls much of these things (maybe even all,dont' remember).
basically the worker process can recycle itself at certain times/intervals, when the memory reaches a certain amount, after being idle for too long and so on. The worker process also terminates when IIS is restarted, or the web.config file touched
Of course, the worker process can abnormally termniate...like if the system crashed ;) or some cltr-alt-deletes the process...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discussions.microsoft.com> wrote in message news:39**********************************@microsof t.com... I understand that static variables have app-domain scope. Till the app-domain is in memory, the static variable will be in memory. When are the app-domains unloaded is the question. I have read somewhere in this forum that statics live till the asp.net process is recycled. Please clarify if someone can. Thanx!
"David Jessee" wrote:
I'd be VERY careful about using a shared page member for state management. its true that there is only that single value for all instances of that type, but there is no way of knowing what the context of that value is doing. E.g. I set PageX.StaticValue1...its value is retained unless there are no longer any instances of PageX in the application's memory. "Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... > I am well aware of state management techniques like Session, Application, > View State, Cookies, etc.. However, I recently discovered that a static > field (variable) essentially acts like an Application variable. If you set > the value of a static field on one page of your ASP.NET application, it is > suddenly avaiable to every session. > > Are there any general guidelines for using this technique? I don't recall > ANY mention of this in training, or documentation online regarding options > for maintaining state. > > Thanks in advance. > Mark > >
the lifespan of static variables is directly tied to the lifespan of worker
process. Static variables are tied to the appDomain...whenever a worker
process recycles, it stops its parent appdomain and starts a new one - state
is not transfered from one to another. This should be useful: http://odetocode.com/Articles/305.aspx
I'm not sure if this was mentioned in the initial thread, but the real risk
with static variables is that you risk having serious race conditions..check
out: http://odetocode.com/Articles/313.aspx
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com... Karl, I undertand that. My question was more to do with the lifespan of a
"static" variable. When does the statc variable really becomes unreachable?
"Karl Seguin" wrote:
The ASP.Net worker process can be recycled under a number of scenarios.
You can control these normal scenarios by going to:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFI G
(c:\winnt on 2000 and framework version might be different) and
opening machine.config (don't mess around in there!). Find "processModel Attributes" and you'll find documentation describing a number of
settings - some of which are used for controlling when the worker process is
recycled. In IIS 6.0, there's an ASP.net tab which controls much of these things (maybe even all,dont' remember).
basically the worker process can recycle itself at certain
times/intervals, when the memory reaches a certain amount, after being idle for too long
and so on. The worker process also terminates when IIS is restarted, or the web.config file touched
Of course, the worker process can abnormally termniate...like if the
system crashed ;) or some cltr-alt-deletes the process...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discussions.microsoft.com> wrote in message news:39**********************************@microsof t.com... I understand that static variables have app-domain scope. Till the app-domain is in memory, the static variable will be in memory. When are the app-domains unloaded is the question. I have read somewhere in this forum that
statics live till the asp.net process is recycled. Please clarify if someone
can. Thanx!
"David Jessee" wrote:
> I'd be VERY careful about using a shared page member for state management. > its true that there is only that single value for all instances of
that > type, but there is no way of knowing what the context of that value
is > doing. E.g. I set PageX.StaticValue1...its value is retained unless there > are no longer any instances of PageX in the application's memory. > > > > "Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message > news:%2****************@TK2MSFTNGP15.phx.gbl... > > I am well aware of state management techniques like Session, Application, > > View State, Cookies, etc.. However, I recently discovered that a static > > field (variable) essentially acts like an Application variable.
If you > set > > the value of a static field on one page of your ASP.NET
application, it is > > suddenly avaiable to every session. > > > > Are there any general guidelines for using this technique? I
don't recall > > ANY mention of this in training, or documentation online regarding options > > for maintaining state. > > > > Thanks in advance. > > Mark > > > > > > >
Thank you!
"Karl Seguin" wrote: the lifespan of static variables is directly tied to the lifespan of worker process. Static variables are tied to the appDomain...whenever a worker process recycles, it stops its parent appdomain and starts a new one - state is not transfered from one to another. This should be useful: http://odetocode.com/Articles/305.aspx
I'm not sure if this was mentioned in the initial thread, but the real risk with static variables is that you risk having serious race conditions..check out: http://odetocode.com/Articles/313.aspx
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discussions.microsoft.com> wrote in message news:8B**********************************@microsof t.com... Karl, I undertand that. My question was more to do with the lifespan of a "static" variable. When does the statc variable really becomes unreachable?
"Karl Seguin" wrote:
The ASP.Net worker process can be recycled under a number of scenarios. You can control these normal scenarios by going to:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFI G
(c:\winnt on 2000 and framework version might be different) and opening machine.config (don't mess around in there!). Find "processModel Attributes" and you'll find documentation describing a number of settings - some of which are used for controlling when the worker process is recycled. In IIS 6.0, there's an ASP.net tab which controls much of these things (maybe even all,dont' remember).
basically the worker process can recycle itself at certain times/intervals, when the memory reaches a certain amount, after being idle for too long and so on. The worker process also terminates when IIS is restarted, or the web.config file touched
Of course, the worker process can abnormally termniate...like if the system crashed ;) or some cltr-alt-deletes the process...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discussions.microsoft.com> wrote in message news:39**********************************@microsof t.com... > I understand that static variables have app-domain scope. Till the app-domain > is in memory, the static variable will be in memory. When are the app-domains > unloaded is the question. I have read somewhere in this forum that statics > live till the asp.net process is recycled. Please clarify if someone can. > Thanx! > > "David Jessee" wrote: > > > I'd be VERY careful about using a shared page member for state management. > > its true that there is only that single value for all instances of that > > type, but there is no way of knowing what the context of that value is > > doing. E.g. I set PageX.StaticValue1...its value is retained unless there > > are no longer any instances of PageX in the application's memory. > > > > > > > > "Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message > > news:%2****************@TK2MSFTNGP15.phx.gbl... > > > I am well aware of state management techniques like Session, Application, > > > View State, Cookies, etc.. However, I recently discovered that a static > > > field (variable) essentially acts like an Application variable. If you > > set > > > the value of a static field on one page of your ASP.NET application, it is > > > suddenly avaiable to every session. > > > > > > Are there any general guidelines for using this technique? I don't recall > > > ANY mention of this in training, or documentation online regarding options > > > for maintaining state. > > > > > > Thanks in advance. > > > Mark > > > > > > > > > > > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dover |
last post by:
If a class defined as classA, what's the meaning of "static classA
objectA;", within a file scope or a function scope or a class member
function scope?
Many thanks!
|
by: Nicholas Beenham |
last post by:
Hi all,
Is there a way to set the lifespan of a thread.
I am trying to start a process that may or may not have an outcome and want
to finish it after a certain length of time finished or not....
|
by: Chris Clement |
last post by:
I have been handed a project that someone else started and most of it was
developed in the VS.NET design mode. For whatever reasons, when I try to
make changes to the controls in VS.NET design...
|
by: Learning C# |
last post by:
I hope this is an ok place to post real beginner stuff.
Basically I need to know the difference between a field, and a static field.
My book sux and doesn't explain this well. It seems that a...
|
by: Jack Wright |
last post by:
Dear All,
I have declare a static object of my class in a WebService. What is
the life span of this Object? Will GC clean it up if it is not used or
accessed? Or Will the worker process keep it...
|
by: gordon |
last post by:
Hi
I am learning C# from books. I am trying to understand the use of the word
'Static' on a method.
When i look in the autos area (I often like to see what values are being
resolved) i see...
|
by: archana |
last post by:
Hi all,
can anyone tell me differene between public static and private static
method.
how they are allocated and access?.
thanks in advance.
|
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= |
last post by:
Hi;
When a Page object - the code-behind of an aspx page is created - what is
the lifespan of that created object? Is it tied to the session, the
request/response, or is it in a poll and reused...
|
by: David Cox |
last post by:
I found some details on a musical festival, made my plans, and only found
out by chance that the site was two years out of date.
Is there some HTML way of setting a lifespan on a webpage on...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |