it's a long time since I'm trying to figure out the truth about static classes. my point of view: value types are allocated on the stack, link types on the heap when using the new operator. but the nature of the static class is that you cannot instantiate it, and, of course, it is not a value type. so my question is when and where does the CLR allocate memory for static content? about when ... I assume at compile time when the assembly is built, but I'm not sure. and about where ... while I was trying to figure out that I read J.Richter "CLR via C #" and he wrote that the static method of the instance class is allocated on the heap when you instantiate this particular class (along with the pointer type of object and index of the synchronization block). but I do not understand. he is static. it should not depend on any state of the object.so please lighten me
The CLR supports several heaps associated with AppDomain, collectively called "loader heaps." They are different from garbage collected because they do not contain collectable objects, mainly related to the data type. Data types that exist throughout the entire AppDomain life cycle.
Space for static variables is allocated in one of them: HighFrequencyHeap. The JIT compiler makes a selection, the code it generates directly refers to the memory location. Background information is in this MSDN journal article .
, CLR . , , Type , AppDomain - , , , ( , ), .
, CLR CLR . , 'this' , , .
, , - .
Source: https://habr.com/ru/post/1757583/More articles:How do you reuse select commands with Entity Framework? - linqWhere can I start this optimization problem? - optimizationThe highest sum of values ββfor each group in XSL - xqueryComma per loop - c ++Getting the current registered Windows Live ID (Windows Phone 7) - windows-phone-7Best way to hide inline CSS and JavaScript from level browsers - javascriptWhat is the best way to check arr, object, string with jQuery undefined + null + trim (str)! == ""? - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1757586/shape-file-gis-to-text&usg=ALkJrhiU9KMgRb8ravl1sohyK_tTat1NNQOdd Length Matching String - regexIs invure-contrib.jar standardized now? - clojureAll Articles