百科问答小站 logo
百科问答小站 font logo



程序中的堆和栈大小是动态变化的,还是相对固定的? 第1页

  

user avatar   bei-ji-85 网友的相关建议: 
      

堆和栈的大小在加载的时候是确定的,但也是可以调整的,是否允许动态调整完全看操作系统是否支持。

所以,两个问题:

1. 你用的OS是什么?
2. 你用的开发语言是什么?

栈是面向于线程的,堆有可能是整个进程共用的,也可能是有好几个堆,每个线程用各自的。

Windows里MSDN有讲:

       BOOL WINAPI SetThreadStackGuarantee(   __inout  PULONG StackSizeInBytes );      

StackSizeInBytes
The size of the stack, in bytes. On return, this value is set to the size of the previous stack, in bytes.
If this parameter is 0 (zero), the function succeeds and the parameter contains the size of the current stack.
If the specified size is less than the current size, the function succeeds but ignores this request. Therefore, you cannot use this function to reduce the size of the stack.
This value cannot be larger than the reserved stack size.





  

相关话题

  什么才算是真正的编程能力? 
  c#匿名委托获取自身的方法? 
  如果中国一开始就禁止微软和英特尔AMD进入中国大陆地区,现在的中国大陆地区会出现哪些现象? 
  优秀的程序员需要懂那些数学知识? 
  非计算机专业,想刷leetcode,请问在此之前需要做什么准备? 
  ORM 框架能自动防止SQL注入攻击吗? 
  如何看待「年轻人不要用 Visual Studio」的言论? 
  写代码一遍就成功是怎么一种体验? 
  为什么用自然语言进行编程不流行呢? 
  C#下有什么办法可以实现毫秒级的计划任务? 

前一个讨论
普通人骑自行车的时速多少?
下一个讨论
操作系统中到底是谁分配的资源?





© 2025-06-15 - tinynew.org. All Rights Reserved.
© 2025-06-15 - tinynew.org. 保留所有权利