| 1 | void *pu[1024*500];
|
|---|
| 2 | void CmemoryleakDlg::OnBnClickedButton1()
|
|---|
| 3 | {
|
|---|
| 4 |
|
|---|
| 5 | memset(pu,0,sizeof(pu));
|
|---|
| 6 | int cu=1024*500;
|
|---|
| 7 | hWnd_main=this->m_hWnd;
|
|---|
| 8 | bool err1=false,err2=false;
|
|---|
| 9 | MessageBox("Begin");
|
|---|
| 10 | // TODO: Add your control notification handler code here
|
|---|
| 11 | //allocation of 500Ko Pointer
|
|---|
| 12 | for (int i = 0 ; i < cu;i++)
|
|---|
| 13 | {
|
|---|
| 14 | __try
|
|---|
| 15 | {
|
|---|
| 16 | //BYTE *p=new BYTE[1*1024];
|
|---|
| 17 | BYTE *p=(BYTE*)malloc(1024);
|
|---|
| 18 | memset(p,0,1024);
|
|---|
| 19 | pu[i]=p;
|
|---|
| 20 | if (p==NULL)
|
|---|
| 21 | err1=true;
|
|---|
| 22 | }
|
|---|
| 23 | __except(MainFilterFunction(GetExceptionInformation()))
|
|---|
| 24 | {
|
|---|
| 25 | err1=true;
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 | MessageBox("Free Memory about 500Ko Pointer");
|
|---|
| 29 | for (int i = 0 ; i < cu;i++)
|
|---|
| 30 | {
|
|---|
| 31 | if (pu[i]!=NULL)
|
|---|
| 32 | free(pu[i]);
|
|---|
| 33 | //BYTE *p=(BYTE*)pu[i];
|
|---|
| 34 | //delete p;
|
|---|
| 35 | }
|
|---|
| 36 | MessageBox("Allocation 700 Mb");
|
|---|
| 37 | BYTE *ii=new BYTE[700*1024*1024]; //BUG ALLOCATING MEMORY ONLY Windows XP Guest machine VBOX
|
|---|
| 38 | if (ii==NULL)
|
|---|
| 39 | err2=true;
|
|---|
| 40 | if (err1)
|
|---|
| 41 | {
|
|---|
| 42 | MessageBox("err1");
|
|---|
| 43 | }
|
|---|
| 44 | if (err2)
|
|---|
| 45 | {
|
|---|
| 46 | MessageBox("err2");
|
|---|
| 47 | }
|
|---|
| 48 | MessageBox("Fini");
|
|---|
| 49 |
|
|---|
| 50 | }
|
|---|