c++ STL Vector

April 20, 2010 at 12:12:58
Specs: Windows XP, 2 GB
I have declared a vector in my script like this
vector<string> myVector;

at the end before I exit I do a

this clearing the vector deletes it from memory.

See More: c++ STL Vector

Report •

April 20, 2010 at 12:24:02
Okay. It's entirely unnecessary, but okay.

Do you have a question?

Report •

April 20, 2010 at 14:08:00
"clearing the vector deletes it from memory" is not entirely true. It
deletes its elements from memory. The vector itself is not

Report •

December 13, 2010 at 12:42:32
i'm reviving an old post...
my real question was that if thisVector.clear() will only clear the element then how can I delete the vector so the used memory is returned to the OS. Or is it that garbage collection procedure will take care of this...

Report •

Related Solutions

December 13, 2010 at 12:55:56
C++ doesn't have a garbage collector. It has a stack.

That said, the vector appears to be on the stack. Once the variable goes out of scope, the elements will be deleted, and the memory freed.

How To Ask Questions The Smart Way

Report •

Ask Question