Hi guys,
I don't know what's wrong with the following code! I am deleting all pointers, but when I use the "top" command to watch the memory, I can see that still lots of memory is allocated to the program. Am I missing something here to free the memory?
Hi,
the value of container.capacity() after clearing the container is: 16777216
of course this is just a test, but could you please tell me if there is anything wrong with the way I am allocating memory that I should avoid?
and just FYI: the version of OS and g++:
Linux version 2.6.18-5-686 (Debian 2.6.18.dfsg.1-13)
(gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21))
http://www.cplusplus.com/forum/beginner/33449/
Using dynamic allocation makes sense when you use polymorphism or want to create an array with unknown size at compilation time(but exists std::vector)
Yours is a waste of resource
On Windows the memory usage is deallocated after delete section. However you should check the size and capacity members of the vector. They are different.
I think the answer is that after growing size of vector, it holds the memory usage. In other words the memory usage is caused by empty allocated memory space of the vector.