L
Lucas Kanebley Tavares
Hello all,
I have a templatized class which has an attribute as: "T *data", all
constructors initialize it to zero, and then allocate memory for the
array (and that IS done correctly, I've checked).
What I find it strange, is that at one point I have to reallocate the
data, but if I put this in my operator= overload:
if (data != 0) delete data; //mem leak here
data = new T[get_data_size()];
valgrind acuses a memory leak, but I've watched my destructor and
unless I do this there, that memory block is NEVER deallocated (and no
it's not a self-assignment issue, that's taken care of, and the other
object is not the same).
I wonder what is going on. Any thoughts?
Thanks!
Lucas Kanebley Tavares
PS: This is more of a curiosity, to me the program seems fine, and it
has never crashed before, so I take it the deallocation is correct...
just weird...
I have a templatized class which has an attribute as: "T *data", all
constructors initialize it to zero, and then allocate memory for the
array (and that IS done correctly, I've checked).
What I find it strange, is that at one point I have to reallocate the
data, but if I put this in my operator= overload:
if (data != 0) delete data; //mem leak here
data = new T[get_data_size()];
valgrind acuses a memory leak, but I've watched my destructor and
unless I do this there, that memory block is NEVER deallocated (and no
it's not a self-assignment issue, that's taken care of, and the other
object is not the same).
I wonder what is going on. Any thoughts?
Thanks!
Lucas Kanebley Tavares
PS: This is more of a curiosity, to me the program seems fine, and it
has never crashed before, so I take it the deallocation is correct...
just weird...