Boost logo

Boost Users :

Subject: Re: [Boost-users] [SmartPtr] Memory Leak Perhaps
From: Igor R (boost.lists_at_[hidden])
Date: 2010-09-19 08:12:35


> My first guess was a memory leak but I didn't spot anything which smells like that over numerous debug sessions. I'm generally dubious about that because I'm using shared_ptr's. Shallow copy can't be the problem either again 'cause I only insert shared_ptr's (from just-allocated dynamic memory) into my container.

It's not a memory leak, but memory corruption: it seems that you try
to free some memory block twice.

> On the other hand, the problem only occurs upon insertion of a SPECIFIC entry into my container. Strangely enough, if I delete that specific entry manually before the end of my program, everything goes fine! I even checked the count of that specific shared_ptr and it was 1, i.e., I'm not deleting anybody else's memory. I am really confused and left with no clue... Any suggestions?

Maybe you accidentally store a raw pointer to an object managed by
shared_ptr. Or maybe your object internally allocates and frees some
memory, which is also managed in some other place...
I guess it's worth searching calls to "delete" and "free" in your code.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net