"Jesper, Denmark" <JesperDenmark@discussions.microsoft.comwrote in message
news:A61780F0-3D98-4847-8119-1928CF17FBBF@microsoft.com...
Quote:
Hi,
>
I've written a somewhat large program over the years (70.000 lines of code).
When compiling the program I get a 2MB exe file. When running this program I
get an corresponding image in the task manager showing a 40 MB memory
allocation . Yes, the program allocates memory dynamicaly, but no where near
this amout of memory. Of cause I expect some .net stuff is probably also
contained in this allocation. However, if reinstantiating the program several
times, every instance (shown in the task manager) is showing a memory usage
of around 40-50 MB. I thought that code was shared in such scenarios in order
to save memory space.
>
Q: What si happening in .net?
>
Q: Is there any flag/compiler option that I can check/uncheck to a smaller
memory allocation.
>
Best regards
Jesper, Denmark
>
>
First of, there a a lot of significant memory counters available, what kind of memory
consumption are you talking about?
Second, the size of the exe file has strictly nothing to do with the memory consumption when
the program runs.
A 1KB exe can consume Giga bytes of memory when it runs, all depends on what the program is
doing, what kind and how many objects are there allocated at any time.
Note also that your exe is only (a small) part of the assemblies and DLL's loaded when the
program runs. If this is a windows forms application some more memory is taken by the forms
library and the higher number of objects allocated during forms initialization. Also take
into account that every managed program has at least 3 or 4 threads, that means 3 (4) x 1MB
for stack allocation (committed). And the GC heap starts with a allocated (Reserved) size of
32 MB. So, 40MB is really nothing to worry about.
Willy.