C# 2k8 reduce memory usage (simple app takes 10 MB)

c#, memory-management, optimization, visual-studio-2008

Solution

Whatever you do, the CLR will have to be loaded in the process. 10MB is not too much memory and not all of 10MB is private memory (probably most of it is sharable). By the way, it's not like "if your simple app takes 10MB, making it as double as complex (memory-wise) will need twice the memory (basically, it's CLR's memory footprint.)

I just built a simple console application (`for(;;);`). "Resource Monitor" shows it takes ~2.5MB private memory and ~7MB sharable memory.

Problem

I have a simple C# 2008 application which displays a png-picture and handles some simple MouseEvents. Although it's nothing complex, it uses at least 9.5-10 MB of memory (as shown in task-manager) I've already disabled any type of error logging as well as I removed debug and trace symbols. "Optimize Code" is activated. Is there any way to reduce this? Maybe with some options as native compiling of the framework (does this even exist for .NET?) Any idea? Or is this just the price I have to pay for having the .NET-Framework? Edit: 10 MB is not much, i know. But it's going to run on a Citrix Presentation Server (or XenApp as it is called now) which means that there are ~30 users on one server. 30 users * 10 MB = 300 MB only for this little application. Thanks in advance and best regards

Original source