Static is used in the class method. My current problem is that the static variable is saved in the memory. 1. Where is the static variable stored in the memory? 2. How long has the static variable been withdrawn? 3 will excessive static usage cause insufficient server memory? 4. The s... static of different users is used in class methods. My problem now is that the static variable is saved in the memory,
1. Where is the data stored in the memory?
2. How long has the static variable been withdrawn?
3 will excessive static usage cause insufficient server memory?
4. Why does the static variables of different users not affect each other?
Reply content:
Static is used in the class method. My problem now is that the static variable is saved in the memory,
1. Where is the data stored in the memory?
2. How long has the static variable been withdrawn?
3 will excessive static usage cause insufficient server memory?
4. Why does the static variables of different users not affect each other?
When you declare a class method/variable as static, it is bound to and shared by the class, not the object. from a memory management perspective what this means is that when the class definition is loaded into the heap memory, these static objects are created there. when the class's actual object is created in the stack memory and when updates on the static properties are done, the pointer to the heap which contains the static object gets updated. this does help to reduce memory but not by much.
From a programming paradigm, people usually choose to use static variables for your tural advantages more than memory management optimization. in other words, one might create static variables like you mentioned, when one wants to implement a singleton or factory pattern. it provides more powerful ways of knowing what is going on at a "class" level as opposed to what transpires at an "object" level.
Static is stored in the memory. Too much use should cause insufficient memory?