什么时候静态成员获取内存什么时候、静态、内存、成员

2023-09-03 06:27:51 作者:_劳资有罪丶

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

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

 
精彩推荐
图片推荐