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.StaticVal ue1...its value is retained unless there are no longer any instances of PageX in the application's memory. "Mark" <fi******@idono tlikejunkmail.u mn.edu> wrote in message news:%2******** ********@TK2MSF TNGP15.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 1953
The ASP.Net worker process can be recycled under a number of scenarios. You
can control these normal scenarios by going to:
C:\WINDOWS\Micr osoft.NET\Frame work\v1.1.4322\ CONFIG
(c:\winnt on 2000 and framework version might be different) and opening
machine.config (don't mess around in there!). Find "processMod el
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...lik e if the system
crashed ;) or some cltr-alt-deletes the process...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discu ssions.microsof t.com> wrote in message
news:39******** *************** ***********@mic rosoft.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.StaticVal ue1...its value is retained unless
there are no longer any instances of PageX in the application's memory. "Mark" <fi******@idono tlikejunkmail.u mn.edu> wrote in message news:%2******** ********@TK2MSF TNGP15.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\Micr osoft.NET\Frame work\v1.1.4322\ CONFIG
(c:\winnt on 2000 and framework version might be different) and opening machine.config (don't mess around in there!). Find "processMod el 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...lik e if the system crashed ;) or some cltr-alt-deletes the process...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discu ssions.microsof t.com> wrote in message news:39******** *************** ***********@mic rosoft.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.StaticVal ue1...its value is retained unless there are no longer any instances of PageX in the application's memory. "Mark" <fi******@idono tlikejunkmail.u mn.edu> wrote in message news:%2******** ********@TK2MSF TNGP15.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...whe never 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..che ck
out: http://odetocode.com/Articles/313.aspx
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discu ssions.microsof t.com> wrote in message
news:8B******** *************** ***********@mic rosoft.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\Micr osoft.NET\Frame work\v1.1.4322\ CONFIG
(c:\winnt on 2000 and framework version might be different) and
opening machine.config (don't mess around in there!). Find "processMod el 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...lik e if the
system crashed ;) or some cltr-alt-deletes the process...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discu ssions.microsof t.com> wrote in message news:39******** *************** ***********@mic rosoft.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.StaticVal ue1...its value is retained unless there > are no longer any instances of PageX in the application's memory. > > > > "Mark" <fi******@idono tlikejunkmail.u mn.edu> wrote in message > news:%2******** ********@TK2MSF TNGP15.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...whe never 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..che ck out: http://odetocode.com/Articles/313.aspx
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discu ssions.microsof t.com> wrote in message news:8B******** *************** ***********@mic rosoft.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\Micr osoft.NET\Frame work\v1.1.4322\ CONFIG
(c:\winnt on 2000 and framework version might be different) and opening machine.config (don't mess around in there!). Find "processMod el 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...lik e if the system crashed ;) or some cltr-alt-deletes the process...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"abCSharp" <ab******@discu ssions.microsof t.com> wrote in message news:39******** *************** ***********@mic rosoft.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.StaticVal ue1...its value is retained unless there > > are no longer any instances of PageX in the application's memory. > > > > > > > > "Mark" <fi******@idono tlikejunkmail.u mn.edu> wrote in message > > news:%2******** ********@TK2MSF TNGP15.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.
So I have
Thread t = new Thread(new ThreadStart(targetMethod));
|
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 mode, I suddenly get a ton of
these errors:
cs(1189): 'class.form.checkedListBox1' denotes a 'field' where a 'class' was
expected
I was not getting any errors until I made a couple of changes within VS.NET.
So I'm trying to understand why...
|
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 field is scoped
the same and can do the same things.
IE a field is declared in a class instead of a method so all methods of the
class can use it.
And a static field is described in my book as the same?
|
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 alive till it gets
recycled?
Please help
TALIA
| |
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 that there are also static members and non public members.
Could you please explain to me how the static method differs from others,
how static members differ from others?
|
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 for the next request/response
to that page from any session?
--
thanks - dave
david_at_windward_dot_net
|
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 creation so
that, should the creator neglect to remove it, browsers will not render it?
If not should such a mechanism exist?
Perhaps with page expired message?
David F. Cox
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |