My code is something like this. The vector in question is a vector of dynamic bitset from the boost library:  
while(someCondition){
      vector<dynamic_bitset<> > myvector;  
      //some code here
      myvector.push_back(dynamic_bitset<> x) ;
      //some more code
      //myvector use is over now, release it.
      myvector.clear();
      myvector.shrink_to_fit();
      //or swap myvector with empty vector
}  
As above, myvector is created and cleared every iteration of the while loop. I'm analyzing the memory usage of this code by running it in GDB, and in parallel, looking at the memory consumption displayed by the top command. (There are reasons I can't use valgrind).  
I can see that when I push_back new elements into myvector the memory usage percentage for this program goes up in the top command output. However, when I clear the vector and shrink it (or even if I swap it with empty vector), the usage percentage under top doesn't lower. So, in every iteration of the loop the memory usage keeps increasing and eventually uses up most of the RAM.  
How do I prevent this from happening? I'd like the memory of the vector to be released back to the OS every iteration of the while loop. Perhaps, top is not the right way to analyze memory but I've no other option. Any ideas?
