//debug under vc++ 6
#include "stdafx.h"
#include "conio.h"
#include <VECTOR>
#include <IOSTREAM>
using namespace std;
class aaa
{
public:
char *p;
aaa(int i)
{
p=new char[i];
}
~aaa()
{
delete []p;
}
};
int main(int argc, char* argv[])
{
vector <aaa *> m;
for(int i=0;i<100;i++)
{
aaa *mm=new aaa(1024*1024);
m.push_back(mm);
}
cout<<"Clear pointer vector Begin!"<<endl;
getch();
m.clear();
cout<<"Clear pointer vector END!"<<endl;
getch();
return 0;
}
Notice that memory in this instance is not released at all. Maybe vector only concern about the pointer its stores, the real space its points point is not any connection of it.
So maybe you should release the memory before vector.release manually.