Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7651623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:33:15+00:00 2026-05-31T11:33:15+00:00

I was using VS2008. It’s a long time since I last time wrote memory

  • 0

I was using VS2008.

It’s a long time since I last time wrote memory leak code :), until I met this one.
it is reported from: \atlmfc\src\mfc\plex.cpp(29) :

the MFC “CPlex::Create” is invoked when the CMap::SetAt is called while “pAssoc = NewAssoc()” is invoked to assign memory.

I understand that, release a container by just calling “RemoveAll()” is not enough, need to iterate each entry and delete each of them.

But in this case, all I wanted is to used CMap to store the pair, I don’t want the CMap to delete the value pointer it stored. (The other container handles that.)

Note: this memory leak also happened in “CMapStringToPtr”(reported by other developer and googled them, not tested to confirm)

01    typedef CMap <int, int, CNode*, CNode*&> CNodeIndexMap;
02    CNodeIndexMap m_mapIndexToNode;
03    CNode* pNode = ... //This pNode is from another container, which is responsible for the nodes' clean
04    m_mapIndexToNode.SetAt(nIndex, pNode);
      ....
05    m_mapIndexToNode.RemoveAll();

      //Clean node list
06    for(int i = 0; i < lstNode.GetCount(); i++)
07    {
08        CNode* pNode = lstNode.GetAt(i);
09        delete pNode;
10    }
11    lstNode.RemoveAll();

I guess this is a microsoft bug. If that is really the case, what is the data structure I can use to create an “index table” and how to use it properly?

Any idea or comment on this memory leak?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:33:16+00:00Added an answer on May 31, 2026 at 11:33 am

    In short, my code has a memory leak like: (I used CList as example)

    CList<T>* pList = new CList<T>();
    pList.AddTail(...);
    

    If I forget to delete pList;, of course I will have a memory leak, reported as plex.cpp(29)

    The point is: I didn’t add the macro:

    #ifdef _DEBUG
    #undef THIS_FILE
    static char THIS_FILE[]=__FILE__;
    #define new DEBUG_NEW
    #endif
    

    If I add them to the .cpp files, these memory leaks will be reported with the correct file name and line number.

    As I did not add this macro, the first .CPP file that has #define new DEBUG_NEW defined is responsible to report the memory leak.
    That’s why plex.cpp occured in the debug messages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using VS2008 for a C++ project. The code is quite old and has
Using VS2008, why is this OK (not allowed to use 2010). void assert(int exp,
I`m using vs2008. I added a webform with the following code: <form id=form1 runat=server>
I'm using VS2008 and would like to create a compile time warning / error
We're using VS2008 with the built in static code analysis rule set. We've got
I'm using VS2008's designer for doing this. For example if I've a windows form
I am using VS2008 to port code from VC6. When I ran the new
I am using VS2008 for ASP.NET apps. My Solution Explorer has hierarchy like this:
One of my projects was under SourceSafe and I am using VS2008. Recently I
I am using VS2008 with QT 4.7.1 and add-ins. I am new to this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.