如何释放静态变量内存 [英] how to release static variable memory

查看:1419
本文介绍了如何释放静态变量内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何释放静态变量内存

推荐答案

这个问题无关紧要,因为静态变量的内存永远无法释放.如果变量是引用类型,则只能释放该变量所持有的对象的内存.当将包含变量的类类型加载到内存中时,将分配所有静态变量的内存位置,并且只有在卸载该类时才会对其进行重新分配.仅当要卸载拥有此类的应用程序域时,才会发生这种情况.

希望能向您解释.如果您仍有疑问,请给我留言.

干杯!

—MRB
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.

Cheers!

—MRB


在.Net中,您不能-不能控制释放内存.
You can''t - in .Net, releasing memory is not in your control.


分配静态变量的null值.这就是您所能做的.
Assign null value to static variable. That''s all you can do.


这篇关于如何释放静态变量内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆