Advertisement

MS VC++ Problem (Debug/Release)

Started by April 01, 2003 06:47 AM
3 comments, last by Corrail 21 years, 11 months ago
Hi all! I''ve a problem with MS Visual C++. If I compile my program with Debug-config everything works fine. But if I compile it with Release-config some error occur. I think I made some mistakes at dynamic memory management. But I don''t know where! I''m using following code for allocating and deleting arrays: float* test; test = new float[anzahl]; delete[] test; This is right, isn''t it? I''m deleting every memory I allocte after using it. I''m really confused about the face that if I''m calling a void in a loop the void sometimes works fine and sometimes does mistakes. But this only happens if I compile my program with Release-config. What''s very strange too is that if I''m compiling with MS VS 6.0 no windows-error message appears but if I''m compiling with VS.NET an error message with the text "Heap-integry is incorrect" (or something like that). Any ideas?? Thanks a lot! Corrail corrail@gmx.at ICQ#59184081
--------------------------------------------------------There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.There is another theory which states that this has already happened...
You're definitelely allocating and deallocating memory correctly.

But the crash may be caused by some garbage pointer somewhere. It's happened to me before, but I never bothered to fix it , I was giving up on that prject anyway...

Btw, I didn't try anything in vs.net... Only MSVC++ 6.0

[edited by - James Trotter on April 1, 2003 11:14:41 AM]
Advertisement
It does look like a corrupt pointer or you are accessing outside the bounds of an array.

quote:

... I''m calling a void in a loop the void sometimes ...



I''m not totally sure what you mean by this, could you explain it a bit more (if you feel it is relevant).
Hi guyz!

I''ve found the error!!
I''ve done this before:

char* _chrINIFileName;

int SetFileName(char* _chrIn)
{
_chrINIFileName = new char[strlen(_chrIn)];
sprintf(_chrINIFileName, "%s", _chrIn);
return -32768;
}

instead of allocating (strlen(_chrIn)+1)!!!

But thanks a lot for your help!!

Corrail
corrail@gmx.at
ICQ#59184081
--------------------------------------------------------There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.There is another theory which states that this has already happened...
You should use std::string and std::stringstream for that sort of stuff, they aren''t susceptible to buffer overruns.

This topic is closed to new replies.

Advertisement