View Full Version : allocation huge amounts of memory...

02-24-2002, 03:25 PM
what is the best way of allocating huge amounts (5mb and more) of memory (for storing modeldata, bitmaps ...)

presently im using the window api call
to create a new heapobject of the desired size. (but it feels a little strange always to use HeapAlloc to get memory from this heap)

is there any other way to get memory without creating a new heap (malloc doesnt provide enough mem...)

02-24-2002, 03:36 PM
if you are using c++ you could try the "new" command

golgi apparatus
02-25-2002, 04:03 AM
What are you allocating? Just a bunch of bytes? If you use C++'s new operator like this...

unsigned char * buf = new unsigned char[SZ];

...make sure you release it like this:

delete [] buf; // Don't forget the []

golgi apparatus
02-25-2002, 04:05 AM
Another note. Always prefer standard C++ constructs, operators, classes, etc. to Windows or operating specific alternatives. If you ever have to port your code to another platform, it will go much easier.

02-26-2002, 01:10 AM
i also tried using new, but i didnt get enough memory (after some models were loaded i wasnt able to allocate more...).
with heapalloc this works... well i guess i have to stick to it http://www.opengl.org/discussion_boards/ubb/smile.gif thx for the answers