C ++中的全局内存管理在堆栈或堆? [英] Global memory management in C++ in stack or heap?

查看:117
本文介绍了C ++中的全局内存管理在堆栈或堆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在C ++应用程序中声明一个全局数据结构,它会消耗堆栈内存还是堆内存?

If I declare a data structure globally in a C++ application , does it consume stack memory or heap memory ?

例如

struct AAA
{

.../.../.
../../..
}arr[59652323];


推荐答案

由于我对答案不满意,希望同学karjatkar想要学习的不仅仅是一个简单的是/否的答案,这里你去。

Since I wasn't satisfied with the answers, and hope that the sameer karjatkar wants to learn more than just a simple yes/no answer, here you go.

通常一个过程有 5个不同的内存区域分配


  1. 代码 - 文字段

  2. 初始化数据 - 数据段

  3. 未初始化的数据 - bss段


  4. 堆栈

  1. Code - text segment
  2. Initialized data – data segment
  3. Uninitialized data – bss segment
  4. Heap
  5. Stack

如果你真的想了解什么是保存,然后阅读和书签这些:

If you really want to learn what is saved where then read and bookmark these:

编译器,汇编器,链接器和加载器:简要故事(参见表w.5)

内存中程序解剖

这篇关于C ++中的全局内存管理在堆栈或堆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆