20

Why are the static variable data lost and are they not an instance when IIS / ap...

 2 years ago
source link: https://www.codesd.com/item/why-are-the-static-variable-data-lost-and-are-they-not-an-instance-when-iis-application-pools-are-rebooted.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Why are the static variable data lost and are they not an instance when IIS / application pools are rebooted?

advertisements

Why is that if I restart IIS, a static variable's data is lost (e.g. in a webpart property in Sharepoint) but in an instance variable, this is not the case?

This is with IIS7 and Windows Server 2008 R2 x64.

Thanks


If a process is restarted, all variables are lost. But: IIS automatically serializes the session variables into another processes memory when a pool is recyled. When the pool restarts, the session variables are deserialized and thus, restored. This is done with the .NET serialisation feature, which means that all session variables has to be marked with the [Serializable] attribute, otherwise you get runtime excpetions.

Related Articles

Why should the static variable be explicitly defined?

In the class: class foo { public: static int bar; //declaration of static data member }; int foo::bar = 0; //definition of data member We have to explicitly define the static variable, otherwise it will result in a undefined reference to 'foo::bar' M

In php, how can I make sure that the static variables declared in a function will not be restarted each time the function is called?

It seems that a static variable declared in a function is re-initiated whenever the function is called, how can I use the function in a way that re-calling the function will re-use the static parameter? I defined the function 'testStatic' in static.p

Where are the static variables (data segment or heap or BSS) stored?

I obtained conflicting Opinions about static variable storage. Opinion 1 : "A stack static variable stores its value in the heap" Opinion 2 : "A stack static variable stores its value in the data segment". I am confused with these conf

Why does the static variable not point to nil after being initialized?

I am following one example to learn about singletons, but I am little confused with the code, particularly with the usage of static variable. Following is the code: This is where code checks if this is the first time variable is initialized. + (insta

Why does the menu appear in Chrome and FireFox, but not IE?

Why does the top category menu (Everything, Ballet Flats, Boots, etc) - div id="header-bar" - look great in FireFox and Chrome, but be hidden in IE unless you scroll down the page? http://shoeporn.com Any help will be much appreciated :)For me i

Initialization of the static variable for classes in C ++, why include the data type?

I've been learning C++, and I've come across static variable (I have prior knowledge from C89), and in the resource i'm using, they've declared a static variable in a class such as: class nameHere { public: static int totalNum; } int nameHere::totalN

What is the difference between the static variable and the global variable (Java)?

This question already has an answer here: Difference between static and global variable in Java 5 answers I'm so confused by the difference between static variables and the global variables. When I browsing a Java textbook today, my eyes were caught

Why the static initializer allows the reset of the static variable in Java?

I am studying static initializers in Java. I came through a source code as given below: public class A { private static int count = 5; final static int STEP = 10; boolean alive; static { count = 1; } public static void main(String[] args) { A a = new

Why the static variable is shared between threads

In almost all the posts I have read - If two Threads(suppose Thread 1 and Thread 2) are accessing the same object and updating a variable which is declared as static then it means Thread 1 and Thread 2 can make their own local copy of the same object

What is the reason for using the static variable and the instance variable?

I see below code in one of the class private static final Logger defaultLogger = Logger.getLogger(this.getClass()); private Logger logger = defaultLogger; I would like to know why both static and instace variable are declared? Rest of the class uses

What are the static variables when the libraries are statically linked

Let's say I have library (A) implementing the singleton pattern (it has a static variable in its implementation). (A) library is compiled as a static library. Now, let's say I have in my probject: (B), another static library linking statically with (

why the value of the static variable is the same as I changed it to method

public class Demorun { static int x=20; public static void change(int x){ x=10; System.out.println("inside x: "+x); } public static void main(String[] args) { change(x); System.out.println("outside x: "+x); } } output inside x: 10 outs

Questions about the static keyword with functions and data

I have a few questions about the static keyword in C++ (and probably with other languages as well.) What is the purpose of declaring a function as static? void static foo(int aNumber) { ... } How about a static inline function? void static inline foo

How does it java the static variables and the static method? (With a simple code)

I wonder how java initialize these static variables. The code I can't understand is shown blow: public class Main { static int first=test(); static int second=2; static int third=test(); public static void main(String[] args) { System.out.println(fir

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK