什么时候静态成员获取内存 [英] when does static member get memory

查看:114
本文介绍了什么时候静态成员获取内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一类具有静态成员。据我了解所有静态成员是常见的类的所有实例。因此,这意味着静态成员将获得内存只有一次。这哪里是分配内存(堆栈或堆),当该内存得到分配。

I have a class which have a static member. As I understand all static members are common for all instance of the class. So it means static members would get memory only once. Where is this memory is allocated (Stack or Heap) and when this memory get allocated.

编辑::该内存是从实例级内存不同。这怎么内存获得引用。而做这个内存获得分配在编译时

This memory is different from a instance level memory. How this memory get referenced. and Do this memory get allocated at the time of compilation

推荐答案

静态成员总是存储在全局堆中,甚至引用类型的成员。然而,这堆是不正常的垃圾回收堆。更多信息请参阅: HTTP://www.$c$cproject .COM / KB / CS / codeconcepts.aspx

Static members are always stored in the global heap, even reference type members. However, this heap is not the normal garbage collected heap. Find out more here: http://www.codeproject.com/KB/cs/codeconcepts.aspx

这篇关于什么时候静态成员获取内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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