Click here to Skip to main content
15,889,216 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Weird Memory Issues Pin
Christian Graus8-Aug-05 17:56
protectorChristian Graus8-Aug-05 17:56 
GeneralRe: Weird Memory Issues Pin
LighthouseJ9-Aug-05 4:19
LighthouseJ9-Aug-05 4:19 
GeneralRe: Weird Memory Issues Pin
Jose Lamas Rios8-Aug-05 18:25
Jose Lamas Rios8-Aug-05 18:25 
GeneralRe: Weird Memory Issues Pin
LighthouseJ9-Aug-05 4:27
LighthouseJ9-Aug-05 4:27 
GeneralRe: Weird Memory Issues Pin
Jose Lamas Rios9-Aug-05 4:49
Jose Lamas Rios9-Aug-05 4:49 
GeneralRe: Weird Memory Issues Pin
LighthouseJ9-Aug-05 4:54
LighthouseJ9-Aug-05 4:54 
GeneralRe: Weird Memory Issues Pin
John R. Shaw8-Aug-05 18:59
John R. Shaw8-Aug-05 18:59 
GeneralRe: Weird Memory Issues (solved this, another problem though) Pin
LighthouseJ9-Aug-05 4:55
LighthouseJ9-Aug-05 4:55 
This class is more of just an iterator embedded in a class with members in it. That function, MaximumValueReached() does work in my earlier project. About those guarantees, I did some checking and found out when it finishes the iterator, the data in it gets corrupted. I have a pre-increment and post-increment operator and here's the code that did it:

Iterator& Iterator::operator++ () {<br />
... does iteration here ...<br />
	return *this;<br />
}<br />
<br />
// post-increment<br />
Iterator Iterator::operator++ (int) {<br />
	Iterator temp = *this;<br />
	++(*this);<br />
	return temp;<br />
}


In my for loop, I was calling the post-increment operator which in turn calls the pre-increment operator. I think VC knows how to shape the machine code to increment before or after. What was happening is that the code would get to '++(*this);' and go into the pre-increment and work fine then exit back to the post-increment operator. Before the 'return temp;' statement, the iterator is fine, but after it ran the return statement, it's corrupted and I don't know how it became corrupted or deleted since it's running it's own destructor.

I did switch the for statement to the pre-increment iterator and it works until I hit the debug assertion
_ASSERTE(_CrtCheckMemory());
which I said in my first post that I was receiving before. I've read on some sites like MSDN that says it "Confirms the integrity of the memory blocks allocated in the debug heap (debug version only).". I also read that every time you malloc, it adds one to a counter and when that counter is 1 less than 1024 it asserts. I read what this assertion does but it (and web sites) offer no solution to fix it that I can find.
GeneralRe: Weird Memory Issues (solved this, another problem though) Pin
Jose Lamas Rios9-Aug-05 5:31
Jose Lamas Rios9-Aug-05 5:31 
GeneralRe: Weird Memory Issues (solved this, another problem though) Pin
LighthouseJ9-Aug-05 10:28
LighthouseJ9-Aug-05 10:28 
GeneralFound What I Needed Pin
LighthouseJ9-Aug-05 13:59
LighthouseJ9-Aug-05 13:59 
GeneralRe: Weird Memory Issues (solved this, another problem though) Pin
John R. Shaw9-Aug-05 9:20
John R. Shaw9-Aug-05 9:20 
GeneralRe: Weird Memory Issues Pin
cmk9-Aug-05 1:03
cmk9-Aug-05 1:03 
GeneralRe: Weird Memory Issues Pin
LighthouseJ9-Aug-05 5:06
LighthouseJ9-Aug-05 5:06 
Generalread and write the structure to file Pin
pnpfriend8-Aug-05 12:58
pnpfriend8-Aug-05 12:58 
GeneralRe: read and write the structure to file Pin
Tim Smith8-Aug-05 13:15
Tim Smith8-Aug-05 13:15 
GeneralRe: read and write the structure to file Pin
pnpfriend9-Aug-05 3:37
pnpfriend9-Aug-05 3:37 
GeneralGDI Object leak detection Pin
prcarp8-Aug-05 11:37
prcarp8-Aug-05 11:37 
GeneralRe: GDI Object leak detection Pin
Blake Miller8-Aug-05 12:02
Blake Miller8-Aug-05 12:02 
GeneralRe: GDI Object leak detection Pin
prcarp9-Aug-05 2:34
prcarp9-Aug-05 2:34 
GeneralRe: GDI Object leak detection Pin
cmk8-Aug-05 15:17
cmk8-Aug-05 15:17 
GeneralRe: GDI Object leak detection Pin
prcarp9-Aug-05 2:38
prcarp9-Aug-05 2:38 
GeneralRe: GDI Object leak detection Pin
John R. Shaw8-Aug-05 19:39
John R. Shaw8-Aug-05 19:39 
Generalmr MFC please do something when I press a key Pin
Spiritofamerica8-Aug-05 10:29
Spiritofamerica8-Aug-05 10:29 
GeneralRe: mr MFC please do something when I press a key Pin
Stober8-Aug-05 11:02
Stober8-Aug-05 11:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.