MFC App & Physical Memory
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: MFC App & Physical Memory

Hybrid View

  1. #1
    Join Date
    Aug 2012
    Posts
    53

    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.

  2. #2
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,366

    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. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: MFC App & Physical Memory

    And of course, have a look at this FAQ: How to detect memory leaks in MFC?
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,880

    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.

  5. #5
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: MFC App & Physical Memory

    Quote Originally Posted by OReubens View Post
    note that the item posted by Ovidiocucu only detects memory leaks caused by new/delete [...]
    Correct, except my nickname.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,972

    Re: MFC App & Physical Memory

    Quote Originally Posted by Don Guy View Post
    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

  7. #7
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,610

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center