百科问答小站 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.





  

相关话题

  中国计算机专业的大学生相比于美国差在哪里? 
  程序员发现 Bug 的时候是怎样一种心境? 
  DirectX是谁开发的?有什么过人之处? 
  如何通过自学找到一份开发的工作? 
  一行 Java 代码(以分号结束)能实现什么丧心病狂的功能? 
  Python 中有什么不容易让人察觉的有趣的事实? 
  男朋友的大脑是单线程的怎么办? 
  在宿舍写代码总被一个室友认为在装逼,该怎么办? 
  程序员如何简单易懂的向老板解释架构的重要性? 
  喜欢编程而又干着程序员的工作是一种什么样的体验? 

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





© 2025-05-04 - tinynew.org. All Rights Reserved.
© 2025-05-04 - tinynew.org. 保留所有权利