Memory Allocation in C++/C

Data Segment - Global +static data which are initialised to non-zero values.

Bss - Global +static data which are initialised to zero by default.

Heap -Dynamically allocated.

Stack - Local or Auto variables
Apart from all the discussions, i read one article where there will be compiler documents which comes along with the compiler which specifies where these segments are created and how they are used.

Usually, the compiler used by intel processors contain a code segment ,data segment.

Where in the code segment is the read only area.
Data segment in turn contains stack and heap. Where heap grows from bottom to top and stack grows from top to bottom of DS.

--------------
stack |
--------------
|
--------------
|
--------------
heap |
--------------

 

Don't get confused with data segement and heap. They are different.

Data Segment - Global +static data which are initialised to non-zero values.

Bss - Global +static data which are initialised to zero by default.

Heap -Dynamically allocated.

Stack - Local or Auto variables

Since the heap memory is seperate from stack, you can very well access it from outside a func, even it is allocated in a func.

C++ Memory Management: From Fear to Triumph


by George Belotsky
05/08/2003
http://www.linuxdevcenter.com/pub/a/linux/2003/05/08/cpp_mm-1.html?page=1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值