I have a strange error. My debug build works well, but my release build crashes after succesful build. In my code:
1 2 3 4 5 6 7 8 9 10 11
this->MaxFrames = MemAllocator.MaxFrames;
// show me how much byte i need ?
//std::ostringstream asd;
//asd<< ( this->MaxFrames * sizeof(D3DXMATRIX) );
//MessageBox(NULL,asd.str().c_str(),"bilgi",MB_OK);
// allocate memory for the FinalMatrices array
FinalMatrices = new D3DXMATRIX[this->MaxFrames];//ERROR HERE!
But when i uncomment MessageBox function, it doesn't crash :D What is happening ?
1 2 3 4 5 6 7 8 9 10
this->MaxFrames = MemAllocator.MaxFrames;
std::ostringstream asd;
asd<< ( this->MaxFrames * sizeof(D3DXMATRIX) );
MessageBox(NULL,asd.str().c_str(),"bilgi",MB_OK);
// allocate memory for the FinalMatrices array
FinalMatrices = new D3DXMATRIX[this->MaxFrames];//NO ERROR!
Those bad alloc errors can be pretty complicated. The problem can be in any other part of code with bad class casting or procesing after allocated array space or any other bug with peeing in memory where you can't pee... debug program allocates memory in different way than release so thats why those problems can occure even only in one case. Sorry for not helping. All I wanted to say is - consider checking other parts of code for bugs.
I checked my code but i have no leak. My program trying to allocate 2kb memory. I have 4gb ram :D
and std::string::c_str() method returns a LPCSTR(long pointer C STRing)
I tried using sleep instead of messagebox but i get error. MessageBox is a magician i think :D
If that message box is really keeping your program stable, you have some notable design issues (possibly algorithm issues). I would reconsider a redesign of your function.