MFC App & Physical Memory
Hello there,
I have a MFC app developed in VS 2012. Inside couple of worker threads it's constantly doing bunch of things.
Now if i start the app and then open the Task Manager and look at the Physical Memory for my app, it's constantly incriminating until i close the app.
I didn't try to run the app for more than an hour yet, as i am not sure whether that will screw up other app's in the system.
What does this increase in Physical Memory mean? Is this a problem?
If yes, how can i fix that?
Thanks in advance.
Re: MFC App & Physical Memory
Quote:
What does this increase in Physical Memory mean? Is this a problem?
If yes, how can i fix that?
It means that the program is constantly obtaining more memory and not releasing memory it has previosuly obtained. This could be caused by repeatedly creating some new resource and not deleting a previous resource first - or allocating mmeory and not freeing it when needed.
It is a problem and you will need to examine the program to see what is happening. There are tools available which can assist you with this.
You haven't provided any code so can't really comment. But, for example, one issue could be creating brushes in a message handling function and not deleting them etc.
Re: MFC App & Physical Memory
And of course, have a look at this FAQ: How to detect memory leaks in MFC?
Re: MFC App & Physical Memory
note that the item posted by Ovidiocucu only detects memory leaks caused by new/delete (getmem/freemem).
It does not detect memory leaking through other means.
Re: MFC App & Physical Memory
Quote:
Originally Posted by
OReubens
note that the item posted by Ovidiocucu only detects memory leaks caused by new/delete [...]
Correct, except my nickname. :) ;)
Re: MFC App & Physical Memory
Quote:
Originally Posted by
Don Guy
Inside couple of worker threads it's constantly doing bunch of things.
You should carefully review that "doing bunch of things" regarding object allocations and deallocations. For the start you may put a breakpoint in object destructors to see if those really called and find this way the problem one.
A special case may be COM objects not released properly.
Quote:
What does this increase in Physical Memory mean? Is this a problem?
Yes, this is a real problem, as physical memory is a limited resource going to be exhausted sooner or later resulting in a crash or hanging up.
Re: MFC App & Physical Memory
As stated, an increase in memory is a problem, but only if it continues forever. Leave your app for a few hours or days to see what happens. Many allocators can behave in a way that makes you think that you have a leak when you in fact don't. The reason is that it can be very beneficial in terms of performance not to deallocate memory immediately.
I can recommend a tool called Visual Leak Detector to help you find any leaks.