468,512 Members | 1,501 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

weird Debug error! damage after normal block ...

Hi,

I receive this "Debug Error!" message while deleting the CContext instance.
e.g.

CContext pCC = new CContext();
// ... do something on pCC
delete pCC; // error message pops up here.

I've given below the code fragment for the class.
If any of the data members is commented and moved outside of the class as a global variable, the error message disappears.

Does anyone have an idea?
thanks,
mk

// Context.h
class CContext
{
public:
CContext(void);
~CContext(void);
// ...
// member functions
// ...

// if one of the below data members is commented and moved outside of the
// class as a global variable, error message disappears.
List<CS>* m_SList;
List<CW>::LNode* m_WIterator;
List<CS>::LNode* m_SIterator;
CDB* m_DB;
List<CUF>* m_Files;
CGC* m_GC;
CPT* m_PT;
};

// in Context.cpp
CContext::CContext(void)
{
m_SList = new List<CS>();
m_WIterator = 0;
m_SIterator = 0;
m_DB = 0;
m_Files = new List<CUF>();
m_GC = new CGC();
m_PT = 0;
}

CContext::~CContext(void)
{
if (m_SList) delete m_SList;
if (m_DB) delete m_DB;
if (m_PT) delete m_PT;
if (m_Files) delete m_Files;
if (m_GC) delete m_GC;
}
Jul 25 '06 #1
2 7715
Banfa
9,056 Expert Mod 8TB
I think what this error is trying to say is that you have over written a block of allocated memory, e.g. allocated a block of 10 bytes and written 20 bytes to it.

Since you have left out the methods invoked on the class and the definition for those methods and the error is most probably in that code there is little more I can say.


1 thing I will say is that assuming you have a typo and are using the STL list there is little point declaring

List<CS>* m_SList;

and newing your list, an empty list has very little overhead you may as well simplify things and just declare

List<CS> m_SList;

unless you have actually got to the point where you are counts bytes used and trying to minimise them.
Jul 25 '06 #2
Yes, somehow the allocated block gets damaged before deletion, but I can not explain the behaviour.

If any of the members is moved outside of the class, the message disappears.

I realised that it occurs only on certain input data.
It seems I need to debug more.

Regarding the List, I'm not using the one in STL.

Thanks for the reply.

I think what this error is trying to say is that you have over written a block of allocated memory, e.g. allocated a block of 10 bytes and written 20 bytes to it.

Since you have left out the methods invoked on the class and the definition for those methods and the error is most probably in that code there is little more I can say.


1 thing I will say is that assuming you have a typo and are using the STL list there is little point declaring

List<CS>* m_SList;

and newing your list, an empty list has very little overhead you may as well simplify things and just declare

List<CS> m_SList;

unless you have actually got to the point where you are counts bytes used and trying to minimise them.
Jul 26 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Deutsche Dogge | last post: by
8 posts views Thread by Vishal | last post: by
5 posts views Thread by Jim Strathmeyer | last post: by
10 posts views Thread by David Thole | last post: by
6 posts views Thread by kwest | last post: by
14 posts views Thread by WStoreyII | last post: by
reply views Thread by P Pulkkinen | last post: by
2 posts views Thread by TamaThps | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.