Click here to Skip to main content
13,197,200 members (57,992 online)
Rate this:
Please Sign up or sign in to vote.
I know some programming (C/C++, JAVA, Win32..), but I don't know advanced concepts of Computer Science. I just know the basics. This question is about memory management in Windows Operating Systems. You can see the problem by just observing.

1. Open a file using Notepad by double clicking a file.
2. Open the Task Manager, and under processes tab you'll find the memory taken by the Notepad.exe (it is about 1,400 K)
3. Then open a file using the Common Dialog Boxes Library which is used in Notepad (Goto File --> Open).
4. Now you'll see the memory taken by Notepad.exe in the Task Manager as about 8,000 K.

Why is that ? And Even After when closing the Open File Dialog, the memory will not change. Why isn't Windows (or the library or anything else) freeing the memory after closing the Open File Dialog.

Need a good Answer !

[I'm using Win7 64bit)
Posted 19-Aug-12 7:51am
Wes Aday 19-Aug-12 13:59pm
The reason is very simple. Task manager lies. If you want a real answer, conduct an actual test.
Pravinda Amarathunge 19-Aug-12 14:42pm
how do i supposed to do that ?
Wes Aday 19-Aug-12 15:45pm
You are developer, write a program. If you want to see how much memory object take up then use a profiler.
Very correct but perhaps not very informative... :-)
Would you take a look at my answer where I give a bit more precise advice on how to "write a program" properly?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

As Wes said, the task manager is telling you how much RAM the process has allocated to it for use, not how much it is using. It is good for a vague idea, or to show a runaway process, but it's not accurate at the granularity you're wanting it to be.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I can give you a more specific idea if you have problems with memory allocation, such as memory leak, of not-enough-memory problems. The type of product you need is called "memory debugger".

You can find the one suitable for you from this list:[^].

At least some of these products are open-source.

Another (but not alternative, it could be the additional) approach is the validating library which you can use during run-time. Such library intercepts/replaces C++ memory allocation operations and count the balance. It can pinpoint the object where the memory is not completely released. Unfortunately, I cannot point you a particular 3rd-party library which you can use with contemporary C++ compilers, but if you use Visual Studio, you can use its debugger along with CRT libraries to detect and pinpoint memory leaks. Please see:[^],[^].

You can improve your memory handling experience and reduce amount of manual work if you use some more advanced techniques like automatic pointers, which provide limited garbage collection facility for pointers:[^].


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171020.1 | Last Updated 20 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100