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:

  1. make array static or declare @ top level of module. way allocated in .bss segment instead of stack.
  2. use malloc/new explicitly allocate array on heap.
  3. use c++ collections such std::vector instead of arrays.
  4. increase stack size limit. on linux can done ulimit -s unlimited

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -