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. A Frame/view/doc question!

A Frame/view/doc question!

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomperformance
4 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.
  • Z Offline
    Z Offline
    zhangyifei
    wrote on last edited by
    #1

    I want to Create a Frame/view/doc structure On a ActiveX Control,but It will be Found Memory leak! And I Found that the reasons is : CDocManager* CDocManager::pStaticDocManager; CPtrList* CDocManager::pStaticList; How Can I avoid Memroy leak? the Following is My Code : BOOL Create() { if( m_pFrameWnd ) { if( IsWindow(m_pFrameWnd->m_hWnd) ) return TRUE; } CSingleDocTemplate * pDocTemplate; pDocTemplate = new CSingleDocTemplate(IDR_MAPTYPE, RUNTIME_CLASS(CMapDoc), RUNTIME_CLASS(CMapFrame), RUNTIME_CLASS(CMapView)); CMapDoc * pDoc = new CMapDoc; CCreateContext Context; Context.m_pCurrentDoc = pDoc; Context.m_pNewDocTemplate = pDocTemplate; Context.m_pNewViewClass = RUNTIME_CLASS(CMapView); Context.m_pLastView = NULL; Context.m_pCurrentFrame = NULL; CMapFrame * pFrameWnd = new CMapFrame; m_pDoc = pDoc; m_pFrameWnd = pFrameWnd; m_pDocTemplate = pDocTemplate; CRect rcMap; GetClientRect(&rcMap); BOOL ret = m_pFrameWnd->Create(AfxRegisterWndClass(CS_DBLCLKS), NULL, WS_CHILD|WS_VISIBLE, rcMap,this,NULL,&Context); m_pFrameWnd->ShowWindow(SW_SHOW); return ret; } ZHANGYIFEI

    J 1 Reply Last reply
    0
    • Z zhangyifei

      I want to Create a Frame/view/doc structure On a ActiveX Control,but It will be Found Memory leak! And I Found that the reasons is : CDocManager* CDocManager::pStaticDocManager; CPtrList* CDocManager::pStaticList; How Can I avoid Memroy leak? the Following is My Code : BOOL Create() { if( m_pFrameWnd ) { if( IsWindow(m_pFrameWnd->m_hWnd) ) return TRUE; } CSingleDocTemplate * pDocTemplate; pDocTemplate = new CSingleDocTemplate(IDR_MAPTYPE, RUNTIME_CLASS(CMapDoc), RUNTIME_CLASS(CMapFrame), RUNTIME_CLASS(CMapView)); CMapDoc * pDoc = new CMapDoc; CCreateContext Context; Context.m_pCurrentDoc = pDoc; Context.m_pNewDocTemplate = pDocTemplate; Context.m_pNewViewClass = RUNTIME_CLASS(CMapView); Context.m_pLastView = NULL; Context.m_pCurrentFrame = NULL; CMapFrame * pFrameWnd = new CMapFrame; m_pDoc = pDoc; m_pFrameWnd = pFrameWnd; m_pDocTemplate = pDocTemplate; CRect rcMap; GetClientRect(&rcMap); BOOL ret = m_pFrameWnd->Create(AfxRegisterWndClass(CS_DBLCLKS), NULL, WS_CHILD|WS_VISIBLE, rcMap,this,NULL,&Context); m_pFrameWnd->ShowWindow(SW_SHOW); return ret; } ZHANGYIFEI

      J Offline
      J Offline
      John R Shaw
      wrote on last edited by
      #2

      This is just a guest, but are you deleting m_pDoc, m_pFrameWnd, m_pDocTemplate when you are finised with them? Normaly, I would put code in the destructor to insure that all allocated member items where freed when the class/object was destroyed. Trust in the code Luke. Yea right!

      Z 1 Reply Last reply
      0
      • J John R Shaw

        This is just a guest, but are you deleting m_pDoc, m_pFrameWnd, m_pDocTemplate when you are finised with them? Normaly, I would put code in the destructor to insure that all allocated member items where freed when the class/object was destroyed. Trust in the code Luke. Yea right!

        Z Offline
        Z Offline
        zhangyifei
        wrote on last edited by
        #3

        sorry ,this can't resolve the proplem! you may try it by yourself!look what happen! ZHANGYIFEI

        J 1 Reply Last reply
        0
        • Z zhangyifei

          sorry ,this can't resolve the proplem! you may try it by yourself!look what happen! ZHANGYIFEI

          J Offline
          J Offline
          John R Shaw
          wrote on last edited by
          #4

          Sorry, but there is not enough information for me to fix it. If you have not already, I would recommend you run it through "Bounds Checker" (trail version available). If the memory is allocated in that small piece code you gave then it should be easy to find. Trust in the code Luke. Yea right!

          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