From: Gerhard Wolf on
Hi,

how do i release the allocated memory when using the std::vector?

for example:
std::vector<int> rv_values;
rv_values.push_back(theValue);
? what possible statements does release the memory allocated by
rv_values?
From: Chris ( Val ) on
On Nov 14, 12:53 am, Gerhard Wolf <quisquil...(a)gmx.de> wrote:
> Hi,
>
> how do i release the allocated memory when using the std::vector?
>
> for example:
> std::vector<int> rv_values;
> rv_values.push_back(theValue);
> ? what possible statements does release the memory allocated by
> rv_values?

Look up the 'clear()' and 'resize()' members.

--
Chris



From: Daniel T. on
"Chris ( Val )" <chrisval(a)gmail.com> wrote:
> Gerhard Wolf <quisquil...(a)gmx.de> wrote:

> > how do i release the allocated memory when using the std::vector?
> >
> > for example:
> > std::vector<int> rv_values;
> > rv_values.push_back(theValue);
> > ? what possible statements does release the memory allocated by
> >
> > rv_values?
>
> Look up the 'clear()' and 'resize()' members.

If clear() or resize() don't do what you want, then look up the swap
trick in (http://www.gotw.ca/gotw/054.htm)