Results 1 to 4 of 4

Thread: Big ol' varible

  1. #1

    Thread Starter
    Addicted Member Cbomb's Avatar
    Join Date
    Jul 1999
    Posts
    153

    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

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Change the two
    Code:
    for( = 0; i < NUMBUFS; i++)
    to

    Code:
    for(i = 0; i < NUMBUFS; i++)
    An i is missing?
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width