-1

We have a c# .NET app that has a footprint of about 300 MB.

My questions:

  1. Do you monitor the memory footprint of your applications?
  2. Is this 300MB footprint bad?
  3. Are there guidelines out there?
razlebe
  • 7,134
  • 6
  • 42
  • 57
bstack
  • 2,466
  • 3
  • 25
  • 38
  • 3
    It's only "bad" if it's not what you would expect for what your application does. Do you have any reason to expect a footprint of 300MB to be excessive? – razlebe Aug 24 '11 at 10:16
  • No reason, just wondering is it bad to have a memory footprint that excessive... – bstack Aug 24 '11 at 11:20
  • 1
    OK, thanks. My point is, "excessive" is relative to expectation. If your program is opening & reading in a 299MB file, then a 300MB footprint isn't excessive. If your program is "Hello World", then it probably is. Without a bit more information, it's impossible to advise as to whether it's excessive. The best advise is that already provided below, which is that it's only a problem if (a) you can't spare 300MB of memory, or (b) the footprint is growing, indicating a memory leak. – razlebe Aug 24 '11 at 11:33
  • The app footprint is not growing. As we can spare enough memory it is not an issue so... – bstack Aug 24 '11 at 12:19

4 Answers4

2

Short answer:

We have only once monitored the memory usage of a WPF application, which went on to become pretty serious caused by a bug by one of our third party controls.

Since .NET offers a managed Framework, the only guideline probably is to not worry about memory as long as it does not become a concern. The GC can handle itself pretty well and as long as their is memory still available, why not use it?

So when does it become a concern? Getting out of memory exceptions could be your point when you need to start to worry. I personally have never seen that happen though.

2

As a rule a static memory footprint is not a problem however large it is, unless it is causing problems on the target computer. The real problem with memory is when you have memory leaks, where the memory is increasing.

The reason I never bother is that I have no idea what a good or bad memory footprint is for a particular application. I think there are better routes to identifying issues within your code than focussing on memory. In simplistic terms, if your code is well written, and you have removed unneeded references, then your memory footprint will be right.

Schroedingers Cat
  • 3,099
  • 1
  • 15
  • 33
  • We dont have memory leaks, just worried that a 300MB momory footprint is too large! – bstack Aug 24 '11 at 11:24
  • It is, if you only have 200MB available. On the other hand, if you have 2GB available, it is not. –  Aug 24 '11 at 13:18
1

The most important thing is that it does not grow over time. To asess this correctly, it can be useful to do some occasional forced garbage collections, preferably at a time when you expect memory use to be low.

In our GUI app, we do this when a session is closed, which is every 10 minutes or so. If people oppose forcing a GC in a release app, you can make this a debug-build only feature.

  • We dont have a problem with the memory footprint increasing, hence we wouldnt need to force garbage collection. I am just worried that a 300MB momory footprint is maybe too large? – bstack Aug 24 '11 at 11:27
  • @bstack: it will be too large for a machine with only 256MB memory. Our app, with 20-ish dlls, takes 250MB after startup. This never worried me. Most of this is excecutable and CLR overhead. The managed heap is almost empty. You can check this with perfmon, with the counters in the ".NET Clr memory" category. –  Aug 24 '11 at 13:35
1

I would only worry if the memory grows over a period of time - you may need to use automated testing to repeat operations over and over again in order to expose such memory leaks (see How to test a WPF user interface?)

If you are really worried I would look into using a memory profiler such as Redgate ANTS Profiler or if you want free try CLRProfiler4; the latter is hard work to use but it will still find memory leaks with patience.

Community
  • 1
  • 1
Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56