Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple .NET processes memory footprint

I am developing an application suite that consists of several applications which user can run as needed (they can run all at the same time, or only several..).

My concern is in physical memory footprint of each process, as shown in task manager.

I am aware that Framework does memory management behind the curtains in terms that it devotes parts of memory for certain things that are not directly related to my application.

The question. Does .NET Framework has some way of minimizing memory footprint of processes it runs when there are several processes running at the same time? (Noobish guess ahead) Like, if System.dll is already loaded by one process, does framework load it for each process, or it has some way of sharing it between processes?

I am in no way striving to write as small (resource-wise) apps as possible (if I were, I probably wouldn't be using .NET Framework in the first place), but if there's something I can do something about over-using resources, I'd like to know about it.

like image 750
mr.b Avatar asked Jun 10 '10 14:06

mr.b


1 Answers

When NGEN is used to pre-JIT assemblies, it is done in such a way that if the same assembly is loaded into multiple processes the executable code can be shared between them (otherwise each process has to have a copy of both the original IL and the JIT-compiled code).

Most (all?) of the base libraries in the framework are NGEN compiled when the framework is installed partly for this reason (also to decrease the initial startup time of .NET applications)

Rico is the undisputed expert on this: http://blogs.msdn.com/b/ricom/archive/2004/10/18/244242.aspx

Furthermore many of those pages can be shared across processes so we like to encourage putting sharable code into ngen’d images – jitted code can’t be shared.

like image 139
StarryNight Avatar answered Oct 05 '22 00:10

StarryNight