1

While working with a .NET application which references a large number of libraries (some third party, some not), several questions came up regarding performance and the use of libraries in .NET applications.

Considerations

When referencing a large number of libraries, what considerations come into play? For instance, I would imagine that there may be performance/memory hits during start-up.

Profiling

I know how to get the list of loaded modules using tasklist /M from the command line, but are the ways to measure the memory footprint of the application's referenced libraries (I realize that it's likely that many are shared), or the time it takes to load all of them?

Optimization

Are there ways to defer loading libraries until they are needed? Looking at the loaded modules for my application, I'm seeing modules which likely are not needed by the average user, but are loaded just in case. This question of course assumes that there is some non-negligible cost associated with loading modules.

Brian Gradin
  • 2,165
  • 1
  • 21
  • 42
  • 3
    Libraries in .NET are not loaded till needed already. If you are seeing them in the module list something in your program used a resource from that library already. – Scott Chamberlain Feb 13 '15 at 19:42
  • Is there any way to identify the section of code which caused a module to be loaded other than by guess and check? – Brian Gradin Feb 13 '15 at 19:48
  • 3
    Subscribe to the [`AppDomain.CurrentDomain.AssemblyLoad`](https://msdn.microsoft.com/en-us/library/system.appdomain.assemblyload.aspx) event. Put a breakpoint in there then do a debug step, the next line of code it jumps to should be the block that requested the assembly. – Scott Chamberlain Feb 13 '15 at 19:58
  • I'm afraid this is a bit too broad, if not offtopic for SO. You can though use [ProcessMonitor](https://technet.microsoft.com/en-us/sysinternals/bb896645.aspx) to analyze what files the application is accessing, how often and how long that takes. – CodeCaster Feb 13 '15 at 21:56

0 Answers0