memmory corruption

M

mohi

hello everyone ,
is there any cmmnd in gdb or any other way to find out whats the total
dynamically allocated memory
a process holds at various instances of execution???

and what can be the possible reasons of an error like

glibc detected:malloc() memory corruption

when the program executes almost the same function abt 2000 times with
no error
it does use dynamically alloted space and free it at every function
call


thank you very much
 
J

James Kanze

mohi wrote: [...]
glibc detected:malloc() memory corruption
Buffer overrun, double deletion of memory, attempt to use
dynamic memory after it has been deleted, allocation using
'new[]' then deletion using 'delete' instead of 'delete[]'...

Just about any undefined behavior could in theory cause it.
Using an uninitialized pointer, for example.
If you are sure allocations and deallocations are correctly
paired up, then it probably isn't that particular function...

Back in the old days (in C), about 50% of the time, this was
caused by someone allocating strlen(s) bytes, then using strcpy
to copy into the allocated memory. I you're using C++
correctly (std::string, std::vector, etc.), those sort of
problems should be close to non-existant, but if he's got an
array new anywhere, it's a likely candidate. Another
possibility is that something didn't get recompiled when a
header was modified. So the size of a class changes, but the
operator new uses the old size.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top