Mail Archives: djgpp/1997/06/04/06:17:19
I have 8MB of physical RAM installed on my computer (I know, it sux).
I was just thinking then that the following programs would both fail to
allocate that memory, but they don't... Why?
Program 1:
#include <conio.h>
#include <crt0.h>
int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY;
char buffer[1024 * 1024 * 20]; // 20MB large buffer
int main(void)
{
cprintf("hello, world");
return 0;
}
Program 2:
#include <conio.h>
#include <crt0.h>
int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY;
int main(void)
{
void *buffer = calloc(1024 * 1024, 20;
if (buffer != NULL)
cprintf("Memory allocation successful.");
else
cprintf("Memory allocation failed.");
return 0;
}
Both program swap to disk hence using virtual memory. Why is that,
shouldn't the crt0 flags prevent this? Isn't there a way to make sure that
all memory is locked securely?
// Blizzar -- blizzar AT hem1 DOT passagen DOT se -- http://hem1.passagen.se/dnt
****************************************************************************
Don't tell me about the answer, 'cause then another one will come along soon
I don't believe you have the answer, I've got ideas too
But if you got enough naivity, and you got conviction
then the answer is perfect for you!
// Bad Religion - Generator, The Answer
****************************************************************************
- Raw text -