#ifndef UNICODE
#define UNICODE
#endif
#include <iostream>
#include <Windows.h>
#include <queue>
using namespace std;
void addSomeContent(queue<TCHAR*> &output)
{
TCHAR* buffer;
for(int i=0; i < 10000; i++)
buffer = new TCHAR[1000];
}
int main()
{
queue<TCHAR*> foo;
char sign;
beginning:
addSomeContent(foo);
while (!foo.empty())
{
delete [] foo.front();
foo.pop();
}
wcout<<TEXT("Press y to repeat\n");
cin>>sign;
if(sign == 'y' || sign == 'Y') goto beginning;
return 0;
}
此程序的每次迭代都使用了20MB的RAM。爲什麼不通過這個指令派發?無法從陣列隊列中手動釋放內存
while (!foo.empty())
{
delete [] foo.front();
foo.pop();
}
+1爲你的第二段=)哦..第一個也是發現。 – paddy