HOW TO GET GOOD MEMORY BLOCK?
Well,i''m a newer in programming.
How can i get a large(in MB),easy-accessed,fast block
in Win9x/NT memory?
malloc?....i beleive so.
so, include the header file for the malloc function, then take your variable and do allocate the amount of memory you want for it.
e.g. var1 = (type)malloc(size_of_memory_in_bytes);
hope that helps (or someone prooves me wrong. Which will probably be the case).
so, include the header file for the malloc function, then take your variable and do allocate the amount of memory you want for it.
e.g. var1 = (type)malloc(size_of_memory_in_bytes);
hope that helps (or someone prooves me wrong. Which will probably be the case).
"Now watch as I run away in a womanly fashion." - Batman
Which language? In C or C++ just the standard memory allocation functions work fine:
(Well, I have to type faster... sorry Sponge99 but when I started to reply there were no answers )
Edited by - BitMaster on August 25, 2000 7:29:00 AM
void example1() // I guess c++ only, but I'm not sure{ BYTE * memblock; memblock = new BYTE[NUMBER_OF_BYTES_YOU_WANT]; // do what you want with it delete [] memblock;}void example2() // works in c too{ BYTE * memblock; memblock = (BYTE *) malloc(NUMBER_OF_BYTES_YOU_WANT); // do what you want with it free(memblock); }
(Well, I have to type faster... sorry Sponge99 but when I started to reply there were no answers )
Edited by - BitMaster on August 25, 2000 7:29:00 AM
How many megabytes do you need? I''d suggest using VirtualAlloc and page management for anything over 4 MB...heaps slow down on Windows 3.1''s posterity because of the VMM architecture (methinks). Thankfully, that doesn''t happen on NT. But, I''d use VirtualAlloc anyway.
VK
Using GlobalAlloc in the win32 enviorment always returns memory allocated on a qword boundary, which can be helpful.Also, with many memory management calls, the system allocates more then you ask for (to line up blocks of memory more efficiantly, no doubt GlobalAlloc ends on a qword boundary also), GlobalAlloc does the same thing, but you can also use the GlobalSize function to see the exact number of bytes allocated.Your program will not violate memory protection if you use the extra memory it allocates (unless you use more then what is returned by GlobalSize).
I still prefer malloc
----------
meh
I still prefer malloc
----------
meh
----------meh
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement