Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22002

Free up memory immediately by swap trick (C++) [closed]

$
0
0

I have a very large vector as follows.

vector<vector<int>> a(100000, vector<int>(100000);
// do some work using a here
......

After the work is done, I use

vector<vector<int>>().swap(a);

in order to free the memory used by "a"immediately. I add

sleep(100)

after the swap and use "top" command to see whether memory usage is reduced immediately. But I observe that nothing has changed. What happens here?


Viewing all articles
Browse latest Browse all 22002

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>