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 8078029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:39:42+00:00 2026-06-05T15:39:42+00:00

I enabled heap debugging because of a memory leak error I started seeing in

  • 0

I enabled heap debugging because of a memory leak error I started seeing in somebody else’s code and I pinned down the problem (at least, so I think) to the destructor of a class, right after the call to the delete [] below.

MyClass::~MyClass() {
    delete [] my_class_member_;
}

Now I confirmed that my_class_member_ which is an array of pointers to objects of a struct, say, MyStruct, has been allocated property using new [] so I am not sure what is causing this leak? Here’s what the new [] call looks like:

delete [] my_class_member_;
my_class_member_ = new MyStruct[somesize_]; 

Next, the struct MyStruct is also relatively simple and is as follows (stripped down):

struct MyStruct {
    MyStruct() {}
    ~MyStruct() {
        for( PtrList<PClass>::iterator it(ps); it.more(); it.next() ) {
            delete it.cur();
        }
        for( PtrList<RClass>::iterator it(rs); it.more(); it.next() ) {
            delete it.cur();
        }
        delete shift;
    }
    PtrList<PClass> ps;
    PtrList<RClass> rs;
};

Now PtrList is a list of pointers (a built-in type of the application devkit we’re using).. I am pretty certain that can’t be at fault. Anyways, is anything out of whack that anybody notices here?? Appreciate any insight..

  • 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-06-05T15:39:45+00:00Added an answer on June 5, 2026 at 3:39 pm

    Adding comment as an answer as requested by OP.

    Have you followed the Rule of Three?
    From the information you present it is not clear whether you do so.You need to provide a copy constructor and copy assignment operator which do a deep copy of your dynamically allocated member.If you don’t do so and if both these operators are not private and not left undefined then You cannot be sure that they are not being used at all and this is where your problem lies

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

Sidebar

Related Questions

I enabled heap debugging to try and debug some memory leak errors. I do
I'm having a blast tracking down some heap corruption. I've enabled standard page heap
I tried to increase the heap size like the below C:\Data\Guru\Code\Got\adminservice\adminservice>java -Xms512m -Xmx512m Usage:
While debugging my NServiceBus enabled application, I have certain messages that are reported in
Suppose a1 , b1 , c1 , and d1 point to heap memory, and
I'm trying to find a memory leak in a windows MFC 8.0 application (Release
I've enabled System.Net logging in application configuration and problem is, that xml messages in
In ARC enabled code, how to fix a warning about a potential retain cycle,
I enabled the extension on wamp ( Screenshot ) but I still get this
I have enabled search in my MonoTouch.Dialog. After each keystroke I call the database,

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.