0

I have a console app that watches a folder (Manual code... not using the .Net classes) for file changes, and then does some moving of files based on rules.

However, it seems to shut down by it's self. Crashes, I guess. Now, it's a home project, and I have a 'Hit a key to end' option. I also have a 3 year old walking around. So, it might not be code issue related. However, as a learning exercise, is there a way to get the memory usage of the app? So, I want to know the total amount of memory being used by my app.

Craig
  • 18,074
  • 38
  • 147
  • 248
  • This question is similar to http://stackoverflow.com/questions/750574/how-to-get-memory-available-or-used-in-c – Elian Ebbing Jun 15 '11 at 20:32
  • I understand that you said this was a learning exercise question, but: Having your application log to a file can give you information about how it shut down. "Hit a key to stop" is easier as you are ending the application. You can also use a [`UnhandledExceptionEventHandler`](http://www.switchonthecode.com/tutorials/csharp-tutorial-dealing-with-unhandled-exceptions) to catch and log exceptions before exiting. – unholysampler Jun 15 '11 at 20:36

2 Answers2

1

Try http://msdn.microsoft.com/en-us/library/system.appdomain.monitoringsurvivedmemorysize.aspx

You can also use Process.GetCurrentProcess() and then all memory properties

jgauffin
  • 99,844
  • 45
  • 235
  • 372
1

you could use the System.Diagnostic classes like Process:

Process Properties

do you anyway use a logging system to log all exceptions of your app and a global exception handler for otherwise unhandled exceptions?

Davide Piras
  • 43,984
  • 10
  • 98
  • 147