Re: do you ever found memory leak with STL?

From: Gernot Frisch (Me_at_Privacy.net)
Date: 07/26/04


Date: Mon, 26 Jul 2004 15:49:00 +0200


"rokia" <rokiadd@yahoo.com.cn.discuss> schrieb im Newsbeitrag
news:ce29mq$1f2m$1@mail.cn99.com...
>
> I found many people encounter this problem.
>
> and someone say that it's STL strategy.
>
> but I dont know when will it release those memory.
>
> BoundCheck report there are many memory leak when I use vector to
push_back
> thousands class.
>
> any advice?

Yes. Sure. You're using a pointer to an element inside the vector. Now
you push/pop/remove any element and whoppa - the pointer does not
point to an element anymore, since the STL container re-allocated the
objects. Now you use any member of that object and see funny errors...
Just a thought... Post code if you're not sure.
-Gernot



Relevant Pages

  • Re: Vector and derived classes objects
    ... >> wont be called for the objects the pointer points to, hence I dont see ... > storage for that vector is grown. ... > succeed without throwing to tell you that you've run out of memory. ...
    (comp.lang.cpp)
  • Re: How NOT to code
    ... > I dont find it that bad personally. ... The whole point of that call was to get a monster race pointer and you don't ... the monster's race) without having to use three memory address operators ...
    (rec.games.roguelike.development)
  • do you ever found memory leak with STL?
    ... and someone say that it's STL strategy. ... but I dont know when will it release those memory. ... BoundCheck report there are many memory leak when I use vector to push_back ...
    (comp.lang.cpp)
  • Re: Is this math test too easy?
    ... > communications glitch; one of the more laughable cartoons ... it was loaded into physical memory and, ... > Or one can interpret the character string as one of the values ... A pointer to an integer? ...
    (sci.math)
  • Re: grow list by tail, pointer example recipe -- please comment
    ... manufacturing a pointer with that address. ... the next cons cell. ... believe these lists are in consecutive memory locations. ...
    (comp.lang.lisp)