存储静态变量的位置? [英] where static variables are stored?

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

问题描述

其中静态变量是存储堆还是堆栈。为什么它们全局可用,整个application.how垃圾收集器对它起作用。请给我清楚的解释我对静态变量感到困惑。

where static variables are stored whether heap or stack .why they are globally available entire the application.how garbage collector acts on it.please give me clear explanation i am confused about static variables.

推荐答案

每个静态变量都存储在堆上,无论其类型如何:值类型和引用类型都存储在那里。由于静态变量的生命周期是应用程序的持续时间,垃圾收集器在正常操作期间从不处理它们。



如果它们不是那么它们将不得不基于堆栈,然后它们在不同的线程中不会是相同的变量。
Every static variable is stored on the heap, regardless of the type: value types and reference types are stored there. Since the lifetime of a static variable is the duration of the application, the garbage collector never disposes them during normal operation.

If they weren't then they would have to be stack based, and then they would not be the same variable in different threads.


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

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