1

I am writing an application in C++ using WinAPI calls. I have recently looked at the statistics in Process Explorer and I can see, that the working set of the application is growing. Private bytes remain constant after the program has initialized. I am trying to understand is it a memory leak or not.

Some details:

I am not allocating any memory dynamically in my code using new or malloc. I do call CreateProcess periodically, but I keep reusing the same LPPROCESS_INFORMATION and LPSTARTUPINFO. I also make sure that I call TerminateProcess for each instance and close handles correctly after calling it.

My application performs the same task in multiple iterations, but I have noticed that the working set does have the same value and does not grow with the same speed every time I run the program.

I also know that my code is not leaking any handles. I have double checked it.

Should I be worried about working set growing slowly as the program runs? Can it be that the working set is growing just because of the paging algorithm of OS?

I found a very good question and several good explanations here. But this does not answer my question.

UPDATE: I am using MinGW + Eclipse

Community
  • 1
  • 1
Art Gertner
  • 292
  • 12
  • 27
  • 3
    Have a look at this http://stackoverflow.com/questions/700097/memory-allocation-profiling-in-c Don't count on Windows APIs or the OS to tell you if your app is leaking. Windows memory management is anything but straightforward. Get a memory profiler and profile your app. Then you'll know if it's actually leaking or if the memory manager is just making it look like it's leaking. – Pete May 08 '14 at 20:27
  • Assuming you're developing in VS, do you see memory leak messages in the output when you close the program? If so, you definitely have a memory leak. If not, you still might. :) – dlf May 08 '14 at 20:35
  • @dif, thanks for your comment, I have read, that VS is able to notify about memory leaks, but I am using MinGW + Eclipse... – Art Gertner May 08 '14 at 20:39
  • 1
    @Pete can you suggest a memory profiler the OP should try? – Flortify May 08 '14 at 21:12
  • After reading your comments, guys, I am looking at [this](http://www.puredevsoftware.com/mempro/index.htm), profiler and also these two threads ([link](http://stackoverflow.com/questions/67554/whats-the-best-free-c-profiler-for-windows), [link](http://stackoverflow.com/questions/15167544/c-profiler-on-windows)) – Art Gertner May 08 '14 at 21:23
  • @Flortify Sorry, but I haven't really done unmanaged coding in years, so I don't know what the current tools are in that arena. – Pete May 08 '14 at 21:34
  • You don't need any tools. [`_CrtSetDbgFlag`](http://msdn.microsoft.com/en-us/library/5at7yxcs.aspx) is enough for all your leak detection needs. – IInspectable May 10 '14 at 13:35
  • @IInspectable, I think your comment would be relevant, if I used Visual Studio, but as I have mentioned in original post, I use MinGW + Eclipse – Art Gertner May 10 '14 at 13:44

0 Answers0