I am writing a text Editor application. As an experiment I ran the application and monitered its memory usage on Task Manager as I performed different actions.
-
When I first launched the application, it used 3000 kB.
-
It stayed roughly the same when I typed
-
When I clicked on save, it shot up to 9000kb
-
and then it just stayed at 8500kb (It didn’t go back down to 3000kb)
Is this caused by a memory leak? I’m a bit confused because I observed similar behaviour with Notepad.
- Launching: 1500kb
- Saving: 6000 kb
- After saving, memory stays at around 5000kb
Also, why does my application take up 3x more memory than Notepad.exe, what kind of things could cause that? Should I be worried?
To start with you want to know where that memory is actually being used. There are a lot of complex programs to do memory analysis/profiling, but if you want something more detailed than Task Manager but still fairly simple and free, Sysinternals vmmap is great.
http://technet.microsoft.com/en-us/sysinternals/dd535533
As others have mentioned, the save is probably causing other libraries to be pulled in. The text itself is also going to contribute to your memory usage. VMMap will help you determine how much is yours and how much is other stuff. Then you could see if your part is really growing substantially over time or not. You probably want a large amount of time of stress testing to really see if it is leaking memory if you are not going to use a memory profiler, otherwise the leak is probably not going to be big enough to really notice easily.