Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CPropertySheet::RemovePage in MFC causes memory leak

CPropertySheet::RemovePage in MFC causes memory leak

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studioperformancetutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Serge Desmedt
    wrote on last edited by
    #1

    Hi, In an application we've written we have a dialog based MFC application based on the CPropertySheet class. We are dynamically adding and removing pages while the the dialog is displayed. If the property pages we're adding and removing contain controls (i've tried it with buttons and treecontrols), then we have a memory leak: when I constantly add and remove pages, thus always returning to a same initial state, the application consumes more and more memory. It has nothing to do with the CPropertyPage derived objects themselves. I added several integer members to them, to make the memoryfootprint of the object bigger, but this doesn't cause the memory leak to be bigger. However, when I fill the dialog (by using the dialog editor of visual studio 6.0) with a lot of buttons, then the memory leak is getting bigger. I've added no functionality to the buttons, and not to the CPropertyPage derived class, except for one button with which I can add and remove pages to the CPropertySheet derived dailogbox. Thus it looks like MFC doesn't destroy the dialog template, or the controls on it. The page we're removing is NOT the active page. I've tried explicitly callling destroywindow on the propertypage that gets removed but this does not work neither. The only functionality the application has, is adding and removing CPropertyPage derived objects, so the memoryleak can not be caused by anything else. Does anyone have an idea what can be wrong and how to solve it :confused: Thanks, Serge Desmedt

    T 1 Reply Last reply
    0
    • S Serge Desmedt

      Hi, In an application we've written we have a dialog based MFC application based on the CPropertySheet class. We are dynamically adding and removing pages while the the dialog is displayed. If the property pages we're adding and removing contain controls (i've tried it with buttons and treecontrols), then we have a memory leak: when I constantly add and remove pages, thus always returning to a same initial state, the application consumes more and more memory. It has nothing to do with the CPropertyPage derived objects themselves. I added several integer members to them, to make the memoryfootprint of the object bigger, but this doesn't cause the memory leak to be bigger. However, when I fill the dialog (by using the dialog editor of visual studio 6.0) with a lot of buttons, then the memory leak is getting bigger. I've added no functionality to the buttons, and not to the CPropertyPage derived class, except for one button with which I can add and remove pages to the CPropertySheet derived dailogbox. Thus it looks like MFC doesn't destroy the dialog template, or the controls on it. The page we're removing is NOT the active page. I've tried explicitly callling destroywindow on the propertypage that gets removed but this does not work neither. The only functionality the application has, is adding and removing CPropertyPage derived objects, so the memoryleak can not be caused by anything else. Does anyone have an idea what can be wrong and how to solve it :confused: Thanks, Serge Desmedt

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Platform SDK documentation says that you shouldn't use PSM_REMOVEPAGE message (which is wrapped by CPropertySheet::RemovePage) during processing of some notifications: "A number of messages and one function call occur while the property sheet is manipulating the list of pages. While this action is taking place, attempting to modify the list of pages will have unpredictable results. Accordingly, you should not use the PSM_REMOVEPAGE message in your implementation of PropSheetPageProc or while handling the following notifications and Microsoft Windows messages: PSN_APPLY, PSN_KILLACTIVE, PSN_RESET, PSN_SETACTIVE, WM_DESTROY, WM_INITDIALOG" Tomasz Sowinski -- http://www.shooltz.com

      S 1 Reply Last reply
      0
      • T Tomasz Sowinski

        Platform SDK documentation says that you shouldn't use PSM_REMOVEPAGE message (which is wrapped by CPropertySheet::RemovePage) during processing of some notifications: "A number of messages and one function call occur while the property sheet is manipulating the list of pages. While this action is taking place, attempting to modify the list of pages will have unpredictable results. Accordingly, you should not use the PSM_REMOVEPAGE message in your implementation of PropSheetPageProc or while handling the following notifications and Microsoft Windows messages: PSN_APPLY, PSN_KILLACTIVE, PSN_RESET, PSN_SETACTIVE, WM_DESTROY, WM_INITDIALOG" Tomasz Sowinski -- http://www.shooltz.com

        S Offline
        S Offline
        Serge Desmedt
        wrote on last edited by
        #3

        I'm not doing anything of the above. On the propertypage derived classes there is a button, which sends a message to the propertysheet derived class, who then deletes a page which is not the current active page, and without changing the active page (so PSN_KILLACTIVE and PSN_RESET don't get send). Neither is the dialog startinh or closing, so none of the other meddages get send to the propertysheet. Serge Desmedt

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups