How can I create a varible that takes up 160Mb in memory and then unload it? (memory flush) Thanks in advance.
Printable View
How can I create a varible that takes up 160Mb in memory and then unload it? (memory flush) Thanks in advance.
Couldn't you just keep allocating large blocks of memory until you get to 160MB?
Not totally sure about that, but it should do the trick...I expect the program will die before it allocates 160MB though.Code:#define BUFFER 65536
#define NUMBUFS 2560
// 160MB = BUFFER * NUMBUFS
char **pData;
int i;
pData = new char*[NUMBUFS];
for( = 0; i < NUMBUFS; i++) {
pData[i] = new char[BUFFER];
}
for( = 0; i < NUMBUFS; i++) {
delete[] pData[i];
}
delete[] pData;
Change the two
toCode:for( = 0; i < NUMBUFS; i++)
An i is missing?;) ;)Code:for(i = 0; i < NUMBUFS; i++)
Yep, they're missing...I moved the int i away from both and forgot to put it back again :rolleyes: