Harry Xu on Wed, 18 Jan 2006 19:58:47 -0600 (CST)


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

Re: [ALACPP] memory leak


I believe that you only delete the pointer to the MapSite, not the MapSite object, that is what you leaked memory! sizeof(MapSite)=24.

Ray Tayek <rtayek@xxxxxxxxxxx> wrote:
hi, trying to code up some stuff for a class that i am teaching.
using cxxtest. seems that i am somehow allocating (new) 24 bytes in
the method below. direction is just an
enum(north=0,south,east,west,directions). none of my objects are 24
bytes, so it looks like it is something else, but i can not see it.
is there something that i need to delete in the method below?

thanks

MapSite *Room::setSide(MapSite::Direction direction,MapSite *mapSite) {
map::iterator i=sides_.find(direction);
MapSite *rc=NULL;
if(i!=sides_.end()) {
rc=i->second;
sides_.erase(i);
}
sides_.insert(map*>::value_type(direction,mapSite));
return rc;
}

---
vice-chair http://ocjug.org/

_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp


Yahoo! Photos ? Showcase holiday pictures in hardcover
Photo Books. You design it and we?ll bind it!
_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp