Think Deep,Work Lean

堆和栈

Posted on By zack

前言

关于堆栈,堆是程序员申请的一片内存区域;栈是编译器自动分配释放,存放函数的参数值、局部变量值等。

栈可用用ulimit -a来看,用ulimit -s来改

hugodeMacBook-Pro:code hugo$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4864
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1418
virtual memory          (kbytes, -v) unlimited
hugodeMacBook-Pro:code hugo$ sudo su
bash-3.2# ulimit -s
8192
bash-3.2# ulimit -s 8193
bash-3.2# ulimit -s
8193
bash-3.2# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4864
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8193
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1418
virtual memory          (kbytes, -v) unlimited