c++ - Size of dynamic array vs static array -
what maximum size of static array, , dynamic array? think there no limit dynamic array why static arrays have limited size?
unhandled exception @ 0x011164a7 in stackoverflow.exe: 0xc00000fd: stack overflow (parameters: 0x00000000, 0x00482000)
this looks more runtime error. more precisely - stack overflow.
in places size of array limited available memory. however, limit on stack allocated objects more severe. default, it's 1mb on windows , 8mb on linux. looks array , other data on stack taking more space limit.
there few ways avoid error:
- make array
static
or declare @ top level of module. way allocated in.bss
segment instead of stack. - use
malloc
/new
explicitly allocate array on heap. - use c++ collections such
std::vector
instead of arrays. - increase stack size limit. on linux can done
ulimit -s unlimited
Comments
Post a Comment