context: (from this question reduce the capacity of an stl vector)
Is there a way to reduce the capacity of a vector ?
My code inserts values into a vector (not knowing their number beforehand), and when this finishes, the vectors are used only for read operations. ...
this answer: https://stackoverflow.com/a/1111311/11608725, with the (c++) shrink_to_fit()
https://en.cppreference.com/w/cpp/container/vector/shrink_to_fit seems to provide what the OP asks for.
QUESTION: besides from "manually" [e.g. via shrink_to_fit()
] reclaiming excess allocated memory; will the running process be able to reclaim this memory automatically if needed? or will the memory forever be lost as long as the objects that caused the allocation persist?
does the c++ (11/17) standard impose/guarantee the behaviour or is it entirely up to the compiler and implementation on a specific OS?