• Create Account

### #ActualZoomulator

Posted 03 July 2012 - 05:54 AM

Vectors keep their claim to the memory they've allocated, even after you've cleared it's content. It destructs all the elements, but it does not deallocate them. This is a precaution for when you re-use the vector. If it's grown to a certain size once, it's a good chance it will again. That's how they reason anyway..

If you really want to get rid of the allocated memory, replace the vector with a new empty one to force it. C++11 has included the vector.shrink_to_fit() method, but it's a request that may not be fulfilled by the implementation.

myFollicle = std::vector<myFollicles::myFolliclesLib>();


You only need to explicitly free raw pointers! Never call the destructor or a delete on an object in a container. Vector, when clearing, removing or erasing, will call the appropriate destructor (not delete) on the objects it contains. If this is a raw pointer, the actual object it points to will not be deleted unless you call delete explicitly. It's however recommended to use a unique_ptr in this case rather than a raw pointer.

### #4Zoomulator

Posted 03 July 2012 - 05:54 AM

Vectors keep their claim to the memory they've allocated, even after you've cleared it's content. It destructs all the elements, but it does not deallocate them. This is a precaution for when you re-use the vector. If it's grown to a certain size once, it's a good chance it will again. That's how they reason anyway..

If you really want to get rid of the allocated memory, replace the vector with a new empty one to force it. C++11 has included the vector.shrink_to_fit() method, but it's a request that may not be fulfilled by the implementation.

myFollicle = std::vector<myFollicles::myFolliclesLib>();


You only need to explicitly free raw pointers! Never call the destructor or a delete on an object in a container. Vector, when clearing, removing or erasing, will call the appropriate destructor (not delete) on the object it contains. If this is a raw pointer, the actual object it points to will not be deleted unless you call delete explicitly. It's however recommended to use a unique_ptr in this case rather than a raw pointer.

### #3Zoomulator

Posted 03 July 2012 - 05:49 AM

Vectors keep their claim to the memory they've allocated, even after you've cleared it's content. It destructs all the elements, but it does not deallocate them. This is a precaution for when you re-use the vector. If it's grown to a certain size once, it's a good chance it will again. That's how they reason anyway..

If you really want to get rid of the allocated memory, replace the vector with a new empty one to force it. C++11 has included the vector.shrink_to_fit() method, but it's a request that may not be fulfilled by the implementation.

myFollicle = std::vector<myFollicles::myFolliclesLib>();


You only need to explicitly free raw pointers! Never call the destructor or a delete on an object in a container. Vector, when clearing or erasing, will call the appropriate destructor (not delete) on the object it contains. If this is a raw pointer, the actual object it points to will not be deleted unless you call delete explicitly. It's however recommended to use a unique_ptr in this case rather than a raw pointer.

### #2Zoomulator

Posted 03 July 2012 - 05:45 AM

Vectors keep their claim to the memory they've allocated, even after you've cleared it's content. It destructs all the elements, but it does not deallocate them. This is a precaution for when you re-use the vector. If it's grown to a certain size once, it's a good chance it will again. That's how they reason anyway..

If you really want to get rid of the allocated memory, replace the vector with a new empty one to force it. C++11 has included the vector.shrink_to_fit() method, but it's a request that may not be fulfilled by the implementation.

myFollicle = std::vector<myFollicles::myFolliclesLib>();


### #1Zoomulator

Posted 03 July 2012 - 05:43 AM

Vectors keep their claim to the memory they've allocated, even after you've cleared and destructed it's content. This is a precaution for when you re-use the vector. If it's grown to a certain size once, it's a good chance it will again. That's how they reason anyway..

If you really want to get rid of the allocated memory, replace the vector with a new empty one to force it. C++11 has included the vector.shrink_to_fit() method, but it's a request that may not be fulfilled by the implementation.

myFollicle = std::vector<myFollicles::myFolliclesLib>();


PARTNERS