C # class code loaded in RAM?

I would like to know if the actual C # class code is loaded into RAM when creating the class instance?

So, for example, if I have 2 classes CLASS A, CLASS B, where class A has 10,000 lines of code, but only 1 field, int. And class B has 10 lines of code, as well as 1 int int field. If I create an instance of class A, will it take more memory than class B because of its lines of code?

Additional question: if lines of code are loaded into memory along with the class, will they be loaded for each instance of the class? or only once for all instances?

Thanks in advance.

+3
source share
3 answers

, JITted . , IL- .

- , - . ( ) - JIT- . List<string> List<Stream> , List<int> List<Guid> . (, , .) - - .

+9

A , B. , , , , , . , , , , .., , , .

, , , . , , ( ) .

, , , . , 10 , - 10 000, , IL . IL , .NET Reflector.

+4

This is a good article that describes how and where the JIT IL is uploaded: http://msdn.microsoft.com/en-us/magazine/cc163791.aspx

+1
source

Source: https://habr.com/ru/post/1727455/


All Articles