Maximum stack size or BSS or DATA segment

In C ++, we all know that an array can be in the "main" area as local variables:

int main(){
    int arr[10000];    //on the stack, size can't be very large
    ....
}

or outside the "main" area as global variables:

int arr[10000000];     //on BSS, sie can be very large
int main{
    ....
}

but I want more for this problem.

  • What is the maximum size of an array? I mean the exact meaning.
  • Which will limit the maximum size for the stack, I think the answer is the stack when the thread is created. But for BSS, I really don’t know what it is that will limit its size and is it related to a thread (like a stack) or an application (like a bunch)?
+5
source share
1 answer

. linux ulimit. :

ulimit -a

Linux x64 :

stack size              (kbytes, -s) 8192

- , (2048 linux/pthread), :

int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);

BSS, , : 1,5-2 32- 2 ^ b 64-. , "b" 64:

cat /proc/cpuinfo

:

address sizes   : 36 bits physical, 48 bits virtual
0

All Articles