troubleshooting Question

C++ Programming question  ( simple? )

Avatar of tullhead
tullheadFlag for United States of America asked on
ProgrammingC++* MemoryR
23 Comments1 Solution189 ViewsLast Modified:
Found a memory leak when I delete a ChunkArray.   But I'm not sure how to fix it.  How to a deallocate or recover the memory used in "buffer" ?

class Chunk : public CObject
{
public:
      DECLARE_SERIAL(Chunk);
      void Serialize(CArchive& ar);

      Chunk()
      {
            used = 0;
      }

      ~Chunk()   // 8.0.24
      {
            // How to clean buffer?  
      }

         BYTE buffer[0x2000];  // 8KB
      int used;             // How many bytes of "buffer" are used
};

// Define an Array type for Chunk
typedef CArray<Chunk*, Chunk*> ChunkArray;
ASKER CERTIFIED SOLUTION
pepr

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 23 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros