The Vector Class...
by James Urquhart · in Torque Game Engine · 09/04/2004 (11:38 am) · 3 replies
Hi there,
I was just looking through the source to torque's vector class (core/tVector.h)...
I am looking for a way to delete the mArray in the vector so that the memory of the vector is properly free'd. However, the only place the code seems to do this is in the destructor.
Other times, the code only increments the size of the vector array - it does not seem to go the other way round.
I had thought the clear() function would have at least deleted the array for me, but all it seems to do is set the element count to 0!
My Vector is a static one that stays around for a while.
As far as i can tell, if i add alot of items in the vector, then "delete" all of them shortly after (e.g. with clear()), i'm going to be wasting quite a bit of memory...
Is this an oversight in the design of the Vector class?
I was just looking through the source to torque's vector class (core/tVector.h)...
I am looking for a way to delete the mArray in the vector so that the memory of the vector is properly free'd. However, the only place the code seems to do this is in the destructor.
Other times, the code only increments the size of the vector array - it does not seem to go the other way round.
I had thought the clear() function would have at least deleted the array for me, but all it seems to do is set the element count to 0!
My Vector is a static one that stays around for a while.
As far as i can tell, if i add alot of items in the vector, then "delete" all of them shortly after (e.g. with clear()), i'm going to be wasting quite a bit of memory...
Is this an oversight in the design of the Vector class?
About the author
Associate Kyle Carter