imagine you have an application (single process) written in c#
By default the application is allocating huge virtual memory, far more than it needs (for example the resident memory is about 10mb, while virtual memory is about several GB).
In Java it's possible to use an option to limit this with java -mx128m
How can I do the same for .net / mono application? And the bonus question: is it possible to enforce / change the GC options to always keep as low memory usage as possible (collect as soon as possible, not when system is running out of memory)
basically my goal is to create a .net application with minimal memory footprint
EDIT: in order to make it more clear I insert this scenario, given that nearly every .net application seems to have similar problem:
I run a monodevelop, which is c# application under mono - it eats 1800 MB of virtual memory, while it only uses 291 MB of resident memory. That means the application is using only less than 300mb of memory but it asked for 1800MB for unknown reason. This reason is what I would like to discover as well as the way how to prevent it doing so.
That probably isn't problem for most of users, but it may be problem for applications running on clusters like SGE when task is limited by virtual memory.
Mono has several flags for setting an upper limit on memory like java. For example, when I run my cluster jobs I set the following environmental variable.
setenv MONO_GC_PARAMS max-heap-size=8G
you can see more options available in this question here:
Mono GC max-heap-size isn't documented. Is it safe to use in production?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With