This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to clear the nested vector?


Hi, all

I am having problems with clearing a nested vector.

for example:

// face class, a user defined class.
class face{
 int *A;
public:
 void setup(unsigned n){
   if(!A) A = new int [n];
 }

 ~face() {delete[] A}
};

// define the nested vector.
vector< vector<face> > x;

// somewhere
x.resize(100);

// somewhere
face f;
f.setup(5);
x[20].push_back(f);

/*
  .
  .
  .
  .
*/

x.clear();


but later when I clear x, the memory is not decreasing...

Can someone tell me what is wrong with my procedure? Many thanks!

Note: on Win32 with either VC6.0 , a simple x.clear() is working, but on Linux no way is working.

-- Johnix



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]