Not sure how it works but I have a question:- Does static make the application slow as same variable or method is shared throughout the application, and while one request is using the method or variable other one has to wait for it to be released.
+3
A:
No, it doesn't. It just makes the application thread-unsafe. If you want it to be safe, you must lock the function/variable, and then yes, it has to wait. (This only affects multi-thread environment, if you use only one thread, it doesn't matter, as the function cannot run 'twice' at a time)
Yossarian
2009-12-02 11:53:02
What about memory consumption? Too many static variables can demand a lot of memory that will eventually slow down the OS (as static variables won't collect by the GC).
Eran Betzalel
2009-12-02 12:05:14
+3
A:
No, it doesn't. Also, .NEt doesn't automatically lock variables just because you access them from differnent parts of the program at the same time. You would have to implement the locking yourself.
Maximilian Mayerl
2009-12-02 11:53:44
@Maxmimilian thank you for your response, I have also found that all the static variables are stored in heap as they are not limited to a scope of any object therefore GC will not collect any of the static members until the appdomain now that can slow down the system I think
Pranali Desai
2009-12-02 13:18:21