![]() |
| ||
| Heap block at 003D2CA0 modified at 003D2CB3 past requested size of b (I have 2 queries) I have made a html parser but the memory leaks, as it seems from the message below; is killing me. I am getting this message from gdb debugger (cygwin build). Heap block at 003D2CA0 modified at 003D2CB3 past requested size of b Also now not all the output from cout and printf are getting printed. I am posted the code of main() function where all the pointer acrobatics takes place. The class Parser does the parsing. It can parse from a file or from a character array. It uses an object (buf) of vector<char> to store the output and dynamically instructs vector to resizes when needed using the code... if(bufptr>=buf.size()) buf.resize(buf.size()+INITIAL_BUF_SIZE,'\0'); Query 1: What is the difference between vector's resize and reserve? Quer 2: Do u see any possible memory leaks in the badly hacked code below? int main(){ |
| ||
| Re: Heap block at 003D2CA0 modified at 003D2CB3 past requested size of b Q2: Yes -- there are lots of places that look like memory leeks -- line 24: where is that object deleted? lines 13, 20, and 63: does parse() return a char pointer that needs to be deleted? If it does, then these lines are memory leeks too. |
| ||
| Re: Heap block at 003D2CA0 modified at 003D2CB3 past requested size of b Quote:
Anyway I found the source of the warning from gdb. It is is giving that warning whenever I use the 'delete' operator. I found this after painfully tracing the main() function. e.g. the code if(out) {delete [] out; out=NULL;}which I later inserted at line no. 22 gave this warning from gdb warning: Heap block at 003D4FB8 modified at 003D647D past requested size of 14bdThough I confirmed that 'out' did contain valid data at that moment and the starting address of the block it was pointing to was had the address 0x3d4fc0. I am totally confused why is this happening? Furthermore if I comment out the lines with the 'delete' instructions then I get no warning and while stepping through the code I also get the correct code, but as soon as I run this program directly from the command prompt then it crashes with Windows giving me the message The instruction at xyz location referenced memory at abc location. The memory could not be read.Pls help. I am at my wits end. |
| ||
| Re: Heap block at 003D2CA0 modified at 003D2CB3 past requested size of b does parse() modify the contents of the char array in the first argument to the function ? If it does, then maybe the parse function is overrunning that buffer. |
| ||
| Re: Heap block at 003D2CA0 modified at 003D2CB3 past requested size of b Quote:
Prototype of classes:- struct Property{ |
| ||
| Re: Heap block at 003D2CA0 modified at 003D2CB3 past requested size of b An update. I tried compiling this using MS VC++ 6.0. It compiled well and also runs perfectly (whereas when compiled in GCC it crashes while running. I tried MinGW and Cygwin build of gcc 3.4). But the problem of it crashing, when the 'delete' instructions are uncommented, persists even here. |
| All times are GMT -4. The time now is 5:05 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC