It crashes !
-
void function(void) { int i[1000000]; } int main(int argc, char* argv[]) { function(); return 0; }
-
void function(void) { int i[1000000]; } int main(int argc, char* argv[]) { function(); return 0; }
your RAM memory might not contain that much of memmory. or you try with calloc or malloc
-
your RAM memory might not contain that much of memmory. or you try with calloc or malloc
Hey buddy my RAM is 1 GB.
-
Hey buddy my RAM is 1 GB.
Doesn't matter, how big your memory is. Your data is allocated on stack, and there is a limit for stack size. I'm not sure about default stack (1Mb?), you can check docs for it, you can also adjust its size in compiler settings. But allocation of big memory blocks on stack is very bad practice. Igor Green http://www.grigsoft.com/ Compare It! + Synchronize It! - files and folders comparison never was easier!
-
void function(void) { int i[1000000]; } int main(int argc, char* argv[]) { function(); return 0; }
well i guess itz becoz maybe getting an array if 1000000 integetez basically impliez u need 400000 bytez of location(one block) together (which may not be present/possible!!!!!:~ ).....i dunno.....:~.....if thiz iz a consoole tye that u have done,then ,what kind memory model have u chosen(maybe that could be the reason.....please check that up......i dont see any other reason):~ "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
-
void function(void) { int i[1000000]; } int main(int argc, char* argv[]) { function(); return 0; }
You're allocating 4MB of memory on the stack. Generally, your stack size is a lot less than that. If you need to allocate this amount of memory, allocate it on the heap with a "new" call.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Doesn't matter, how big your memory is. Your data is allocated on stack, and there is a limit for stack size. I'm not sure about default stack (1Mb?), you can check docs for it, you can also adjust its size in compiler settings. But allocation of big memory blocks on stack is very bad practice. Igor Green http://www.grigsoft.com/ Compare It! + Synchronize It! - files and folders comparison never was easier!
I also think Igor Green is correct. And use calloc or new or someother
-
void function(void) { int i[1000000]; } int main(int argc, char* argv[]) { function(); return 0; }
It´s because you are overflowing the stack!! The stack is the part of memory used for keeping function arguments and return adresses when calling a function, but it is also where the LOCAL VARIABLES are kept. By default the size of the stack is 1 MB, and you need at least 4 MB of stack for your "int i[1000000]" array. (4 bytes each int, 1000000 times). You need to make your stack greater. In VisualC++ 6.0: Proyect->Settings->Link->Output->Stack allocations In the "Reserve" text box, try greater values. Bye! :wtf:
-
void function(void) { int i[1000000]; } int main(int argc, char* argv[]) { function(); return 0; }
Variable
i
is a stack-based variable. The default size of a program's stack is 1MB. You have obviously exceeded that amount.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow