Julio Garcia on Thu, 19 Jan 2006 10:13:46 -0600 (CST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [ALACPP] memory leak



24 bytes would be the size of the _Node type for the std::map<MapSite::Direction,MapSite *> you're using (this would be the the same size for nodes of all maps using the std traits, regardless of value_type, I believe). A new node is created everytime you invoke insert.

In the VS2003 implementation, the _Node type contains the following fields (each 4 bytes in size):

    _Left
    _Parent
    _Right
    _Myval
    _Color
    _Isnil

What you're seeing isn't a memory leak. The map itself will deallocate the nodes at destruction time.

Hope this helps,

-Julio.

Ray Tayek <rtayek@xxxxxxxxxxx> wrote:
sorry about the large post, used to java

At 05:39 PM 1/18/2006, you wrote:
> > At 11:21 PM 1/17/2006, you wrote:
> > >hi, trying to code up some stuff for a class ...
> >
> > it's worse than i thought. the code below seems to also have the leak:
> > MapSite *Room::setSide(MapSite::Direction direction,MapSite *mapSite) {
> > MapSite *rc=NULL;
> > pair::iterator,bool>
> > p=sides_.insert(map
> > *>::value_type(direction,mapSite));
> > if(!p.second)
> > { rc=p.first->second; p.first->second=mapSite; }
> > }
> >
> >
> > anybody got a clue
>
>
>Hi Ray! Some questions:
>
>1. What are you using for a leak detection tool?

i am using this plugin:
which
includes cxxtest (and a lot more).


>2. Can you post the code to the whole class?

attached please find.


>3. Why the raw pointers?

haven't studied the latest collection of smart pointers. this is for
a c++ class that i will be teaching in a few days at csulb.edu. which
flavour of smart pointer do you like?


>4. When you put a MapSite into the list, is the map supposed to be the
>sole owner of that object now?

the maze owns the mapsites, his dtor cleans up. and the map is
.

> When the map is destroyed, or when the item
>is removed, is it supposed to be destroyed?

no

thanks

---
vice-chair http://ocjug.org/
_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp


Yahoo! Photos
Got holiday prints? See all the ways to get quality prints in your hands ASAP.
_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp