哪里会分配静态变量的内存? [英] Where memory for static variables will be allocated?

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

问题描述

哪里会分配静态变量的内存?

Where memory for static variables will be allocated?

推荐答案

阅读以下内容:

http://stackoverflow.com/questions/337019/hows-memory-allocated-for-a-static-variable [ ^ ]



http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/1f5d9306-6b81-4d00-8210-3f691f0baf44/ [ ^ ]
Read the following :
http://stackoverflow.com/questions/337019/hows-memory-allocated-for-a-static-variable[^]

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/1f5d9306-6b81-4d00-8210-3f691f0baf44/[^]


分配静态变量时,它将作为 Methodtable 的一部分存储。

Meth odtable 表示在应用程序中第一次加载类时,将在appdomain中为类级变量和类内的方法分配单独的内存。 。



如果静态变量是基本类型,它将作为Methodtable的一部分存储。如果它是引用类型,它将存储在堆内,引用将存储在Methodtable中。
When a static variable is allocated, it will be stored as part of Methodtable.
Methodtable means When a class is loaded first time in application, separate memory will be allocated in appdomain for class level variables and methods inside class. .

If static variable is primitive type, it will be stored as part of Methodtable. If it is reference type, it will be stored inside the heap and the reference will be stored in Methodtable.


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

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