Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / December 2004

Tip: Looking for answers? Try searching our database.

Type loading question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cris - 15 Dec 2004 02:34 GMT
Hi,

When a Type contained in an assembly gets instantiated,
does the whole assembly image gets loaded in memory?

Thanks in advance.

Regards,
Cris
rlander [MSFT] - 16 Dec 2004 22:23 GMT
The CLR employs a pay-for-play type model.

Here is what happens, more or less:

- You load the assembly
- At this point, you consume virtual address space. This is not the
same as physical memory. In most cases this is not a big deal,
particularly on 64-bit systems, like I'm using at the moment. But,
there is actually working set cost here. There is working set cost to
the mapping and to other OS mechanisms. And then the CLR creates a
bunch of data structures for that assembly. This is all before loading
any types. I don't have numbers or percentages handy, but loading isn't
free.
- You load a type
- Here you consume actual memory as we create data structures to
represent the type. The memory consumed here is only for that type and
isn't much -- no IL is loaded yet.
- You instantiate the type (run the class/instance constructor) or call
a method
- Here you consume memory again, as we load the IL for the method and
then JIT the IL, which leaves you with native code. So, here you have
IL and x86 instructions, which is two copies of your code in memory.
- The IL will eventually page away
- Even the jitted code will page away if no longer needed
- rinse and repeat for any other methods that you use on that type or
any other types you use within the assembly

So, you only load what you use. Also, there are some up front costs
that you have to pay for every assembly you load. In general, we advise
folks to generate fewer, larger assemblies.

HTH -- rich

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.