|
-
Jun 1st, 2001, 05:54 PM
#1
Thread Starter
Addicted Member
Big ol' variable
How can I create a varible that takes up 160Mb in memory and then unload it? (memory flush) Thanks in advance.
Last edited by Cbomb; Jun 1st, 2001 at 06:03 PM.
Cbomb
Techie 
-
Jun 1st, 2001, 06:17 PM
#2
Monday Morning Lunatic
Couldn't you just keep allocating large blocks of memory until you get to 160MB?
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;
Not totally sure about that, but it should do the trick...I expect the program will die before it allocates 160MB though.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 1st, 2001, 08:18 PM
#3
Frenzied Member
Change the two
Code:
for( = 0; i < NUMBUFS; i++)
to
Code:
for(i = 0; i < NUMBUFS; i++)
An i is missing?
-
Jun 2nd, 2001, 06:13 AM
#4
Monday Morning Lunatic
Yep, they're missing...I moved the int i away from both and forgot to put it back again
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|