-
February 28th, 2014, 03:42 PM
#1
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.
-
February 28th, 2014, 04:38 PM
#2
Re: MFC App & Physical Memory
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.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 1st, 2014, 01:13 AM
#3
Re: MFC App & Physical Memory
And of course, have a look at this FAQ: How to detect memory leaks in MFC?
-
March 3rd, 2014, 07:36 AM
#4
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.
-
March 3rd, 2014, 09:28 AM
#5
Re: MFC App & Physical Memory
Originally Posted by OReubens
note that the item posted by Ovidiocucu only detects memory leaks caused by new/delete [...]
Correct, except my nickname.
-
March 4th, 2014, 03:03 AM
#6
Re: MFC App & Physical Memory
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.
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.
Best regards,
Igor
-
March 4th, 2014, 05:41 AM
#7
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.
Nobody cares how it works as long as it works
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|