Re: difference between private static and public static.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Mark R. Dawson <MarkRDawson@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi Jon,
in the article there is the comment:

"Every static variable is stored on the heap, regardless of whether it's
declared within a reference type or a value type. There is only one slot in
total no matter how many instances are created. (There don't need to be any
instances created for that one slot to exist though.) Note that this heap is
separate from the normal garbage collected heap - it's known as a "high
frequency heap", and there's one per application domain. "

However, from reading this article:
http://msdn.microsoft.com/msdnmag/issues/05/05/JITCompiler/

It makes the comment that only primitive static types will be stored on the
high frequency heap, whereas static value types and reference types are still
stored on the normal GC Heap.

Ooh, interesting. I'll look into it - thanks very much. The stuff about
the high frequency heap was going on what Willy has said in the past :)

I suspect that it's better for the sake of simplicity to remove the
reference to the high frequency heap and just refer to that article...

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: Please Explain where will the struct be stored if it is declared inside the Class
    ... >> Hi bruce, ... meant the GC heap. ... counter variable lives, well it's on the "High Frequency Heap". ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Please Explain where will the struct be stored if it is declared inside the Class
    ... > Agreed, just one small remark though, The article states "Every static ... > meant the GC heap. ... well it's on the "High Frequency Heap". ... Jon Skeet - ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Struct inside class
    ... From the previous discussion, we know that i1 is a member variable of a strunct in a class, so it's stored on the heap. ... but inside the allocated space for the reference type instance. ... memory leaks and why the .NET good garbage collector is required. ... If GC_ALLOCATE can't allocate the requested ...
    (microsoft.public.dotnet.framework)
  • RE: General Question About Structs and Stack
    ... The memory slot for a variable is stored on either the stack or the heap. ... That includes reference type variables - the variable itself is on the stack, ... method will always be on the stack, whereas a struct variable which is an ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Two questions about C# datatypes
    ... int is value type so it is stored on stack. ... class is reference type ... and it is stored on heap. ... a class containing a struct will create an object where the struct is part of the memory allocated to the object. ...
    (microsoft.public.dotnet.languages.csharp)