Problems With Memory Leak When Implementing_dyncreate?

Here are a few simple steps that can help solve the memory leak issue when implementing_dyncreate.

Approved

  • 1. Download and install the Restoro software
  • 2. Launch the program and follow the on-screen instructions
  • 3. Select the devices you want to scan and restore, then click "Scan"
  • Improve your computer's speed today with this fast and easy download.

    Visual Studio (I’m using 2010, but I’ve tried versions as well) others are telling me that I have a memory leak in the line of my class executing IMPLEMENT_DYNCREATE macros.

    Easily create any MFC dialog application.Add grouping derived from CWinThread using ClassWizard:

    Class CMyThread: public CWinThread  DECLARE_DYNCREATE(CMonThread)Protected:      CMyThread(); // Safe constructor used by Strong CreationPublic:   virtual BOOL InitInstance();    virtual interval ExitInstance();protected:    DECLARE_MESSAGE_MAP();
    #include "stdafx.h"#include "TestProject.h"#include "MyThread.h"#ifdef DEBUG_NEW#undef_debug#define THIS_FILEstatic symbol THIS_FILE[] = __FILE__;#end if// CMyThreadIMPLEMENT_DYNCREATE(CMyThread, CWinThread)CMyThread:: CMyThread()BOOL CMyThread::InitInstance()    // DO: Perform thread initialization here    returns TRUE;int CMyThread::ExitInstance()    // DO: Clean up each thread here    Returns CWinThread::ExitInstance();BEGIN_MESSAGE_MAP(CMyThread, CWinThread)END_MESSAGE_MAP()// CMyThread mind handler

    implement_dyncreate memory leak

    Class CThreadAbstract: public CWinThreadPublic:    virtual BOOL InitInstance() means 0;    mail ExitInstance() = 0;;

    And change your real insteadnew class derived from CWinThread on CThreadAbstract:

    Class CMyThread: public generic CThreadAbstract    DECLARE_DYNCREATE(CMonThread)protected:    CMyThread(); // constructor protected by dynamic creationPublic:    personal BOOL InitInstance();    a kind of electronic integer ExitInstance();protected:    DECLARE_MESSAGE_MAP();

    Now instantiate your own thread from your class’s dialog (OnInitDialog) and exit:

    Approved

    Tired of your PC running like a turtle? Slow, crashing, error-prone? Well, have no fear! Restoro is here to the rescue! This software will quickly and easily repair any common Windows errors, optimize your system for maximum performance, and protect you from file loss and malware. So take a deep breath, sit back, and let Restoro take care of everything. Your computer will be running like new in no time!


    CMyThread (empty) pMyThread = (CMyThread *)AfxBeginThread(RUNTIME_CLASS(CMyThread),0,0,CREATE_SUSPENDED);if(pMyThread)    pMyThread->m_bAutoDelete = false;    pMyThread->ResumeThread();if(pMyThread)    pMyThread->PostThreadMessage(WM_QUIT, 0, 0);    pMyThread = NULL;

    Run the application in the debugger and click OK (or press Esc) to disable it.

    implement_dyncreate memory leak

    IMPLEMENT_DYNCREATE(CMyThread, CWinThread)

    Obviously I don’t know exactly what’s going on here with IMPLEMENT_DYNCREATE on this thing. I’ve read the MSDN files and seen where it says the macro is why it creates an instance of the condition class, so I’m assuming this isn’t actually being cleaned up properly, but I have no idea how it’s supposed to be.