memmory corruption

Discussion in 'C++' started by mohi, Jul 25, 2008.

  1. mohi

    mohi Guest

    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
    mohi, Jul 25, 2008
    #1
    1. Advertising

  2. mohi

    James Kanze Guest

    On Jul 25, 7:15 pm, Victor Bazarov <> wrote:
    > 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.

    > > 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


    > 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.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Jul 25, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GO
    Replies:
    4
    Views:
    513
  2. Devesh Aggarwal

    ADO library corruption

    Devesh Aggarwal, Jul 9, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    429
    Devesh Aggarwal
    Jul 11, 2003
  3. Richard K Bethell
    Replies:
    4
    Views:
    393
  4. AnToine van Maarle

    Windows memmory "read" error

    AnToine van Maarle, May 6, 2004, in forum: Python
    Replies:
    0
    Views:
    330
    AnToine van Maarle
    May 6, 2004
  5. vaysagekv

    Doubt on memmory deallocation

    vaysagekv, Sep 9, 2012, in forum: C Programming
    Replies:
    3
    Views:
    319
    vaysagekv
    Sep 9, 2012
Loading...

Share This Page