B
Bryan Parkoff
"U_BYTE Mem[0x1000000];" is stored in the global variable. It contains
10 megabytes. Do run-time automatically use new keyword to allocate 10
megabytes into memory, and then zero is filled automatically during the
initialization before it reaches to use main() function?
Do you think that it is always unsafe because it may unexpect crash by
not having enough memory? Is it safe to use new keyowrd and fill zero
manually inside main() function?
How much space can global variable be limited? 64KB?
Look at my example code.
If you say that second example is the best, please say the limit in the
global variable as static memory, but not dymanic memory. Thanks...
First Example:
unsigned char Mem[0x01000000]; // 10MB
int main(void)
{
for (int a = 0; a < 0x01000000; a++)
Mem[a] = 0x41;
return 0;
}
Second Example:
unsigned char Mem2[0x00010000]; // 64KB
int main(void)
{
unsigned char* Mem = new Mem[0x01000000];
if (Mem == 0) // exit if NULL
return -1;
for (int a = 0; a < 0x01000000; a++)
Mem[a] = 0x41;
delete [] Mem;
return 0;
}
Bryan Parkoff
10 megabytes. Do run-time automatically use new keyword to allocate 10
megabytes into memory, and then zero is filled automatically during the
initialization before it reaches to use main() function?
Do you think that it is always unsafe because it may unexpect crash by
not having enough memory? Is it safe to use new keyowrd and fill zero
manually inside main() function?
How much space can global variable be limited? 64KB?
Look at my example code.
If you say that second example is the best, please say the limit in the
global variable as static memory, but not dymanic memory. Thanks...
First Example:
unsigned char Mem[0x01000000]; // 10MB
int main(void)
{
for (int a = 0; a < 0x01000000; a++)
Mem[a] = 0x41;
return 0;
}
Second Example:
unsigned char Mem2[0x00010000]; // 64KB
int main(void)
{
unsigned char* Mem = new Mem[0x01000000];
if (Mem == 0) // exit if NULL
return -1;
for (int a = 0; a < 0x01000000; a++)
Mem[a] = 0x41;
delete [] Mem;
return 0;
}
Bryan Parkoff