Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do unused functions/methods of assembly get loaded into memory?

JIT load assembly into memory when any methods of that assembly get called, but if some methods are used and some methods are unused in application of this assembly whether this methods still get loaded into memory?

Also if assemblies loaded into memory with lot of unused functions and methods will it effect performance of that application?

like image 709
user1888859 Avatar asked Dec 12 '25 14:12

user1888859


1 Answers

As @Dennis said, Loading and JIT'ing are two different operations done by two different subsystems in the CLR. But they are dependent.

You have two questions in context, to answer them

  1. JIT doesn't load assembly, the loader does. The metadata of all the classes and its members are loaded in the memory, but the method as such is only JIT'ed on demand (means, when they are called).

  2. The JIT'ed methods don't stay long in memory, unless referenced by someone. The CLR will clean them up based on a clean up procedure. And if that method is needed at a later stage, the method is loaded and is recompiled (JIT'ed) again. So unused functions don't affect application performance in a ideal scenario.

like image 113
Soundararajan Avatar answered Dec 14 '25 04:12

Soundararajan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!