Click here to Skip to main content
15,672,471 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to release static variable memory
RakeshMeena 15-Jul-11 2:52am    
Can you please post your exact problem!

The question is irrelevant, because the memory for static variables can't ever be released. If the variable is of a reference type all that can be released is the memory of the object being held by that variable. When the class type containing the variable is loaded into memory the memory location for all static variables is allocated and it will only ever be deallocated when the class would be unloaded. This only can happen if the application domain that held this class were to be unloaded.

Hope that explains it to you. If you still have doubts leave me a comment.


Share this answer
Prerak Patel 15-Jul-11 3:09am    
Nice explanation, 5!
Manfred Rudolf Bihy 15-Jul-11 3:29am    
Thank you!
You can't - in .Net, releasing memory is not in your control.
Share this answer
Assign null value to static variable. That's all you can do.
Share this answer
Manfred Rudolf Bihy 15-Jul-11 3:04am    
I know what you mean, so take my 5!
See my answer please for an explanation what OP probably got wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900