472,960 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,960 software developers and data experts.

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 7954
Banfa
9,065 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

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

Similar topics

0
by: Deutsche Dogge | last post by:
Hi. I'M having a weird problem with addign menuitems to a menu dynamically on the popup event of the menuitem containing the container of the menuitems i wanna add (tools -> external -> {list of...
2
by: Scott Reynolds | last post by:
I am having a problem exposing a class inherited from the collection base class as a webservice. If I expose the collection on a web page all works well and I am very happy. However when I try and...
3
by: Hasani | last post by:
I'm creating a .net db provider and I came across a weird problem w/ my data reader. The .net provider was created in managed c++ becuase the db api is also c++. I'm calling the code from a c#...
8
by: Vishal | last post by:
Hello, I have uploaded my website from VS to my server and unfortunaly there is an error when I visit the website. However the stack trace of the error still points to my local directory. It...
5
by: Jim Strathmeyer | last post by:
So I'm having some weird problems with file output. If I try to boil this problem down to a small, simple program to just show what problems I'm having, I can't get the same problematic behavior. I...
10
by: David Thole | last post by:
Hey all, I'm still very new at all this, but am going through the ASP.net 2.0 unleashed book, first chapter and trying to program my own little form emailer for fun. I tried following the code...
6
by: kwest | last post by:
I just setup a new server with PHP 5 and ran into a problem with includes. Everytime I call something like require_once './includes/test.inc' I get a permissions message like this: Warning:...
14
by: WStoreyII | last post by:
the following code is supposed to read a whole line upto a new line char from a file. however it does not work. it is producing weird results. please help. I had error checking in there for...
0
by: P Pulkkinen | last post by:
Dear all, sorry, i know this code is far little too long to debug here, but there is really annoying logical error. If someone debugs this, I really offer warm virtual handshake. What this...
2
by: TamaThps | last post by:
Hi, I'm using visual studio 2008 and normally when I get an error it shows what line it is on and which file etc. The error I'm getting I don't know how to solve or even what the problem is. This...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.