Obstack in glibc

本文介绍了Obstack内存管理机制的工作原理及其优势。Obstack能够减少调用系统API malloc() 和 free() 的频率,并允许灵活调整堆栈中对象的大小。通过预先分配内存块并在需要时扩展,Obstack有效地管理内存使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The value of obstack rests upon:
1. It reduces frequency of invoking malloc() and free() system API.
2. You can arbitrarily change the size of object just added to the stack.

How does obstack work?
Namely, obstack is objects in stack, but don't conjecture it with stack very much. Practically, after a new object being added to the stack, the previous objects added in the stack can never be moved or changed.
So you should comprehend the organization of obstack as simple as possible. If you want new memory, that is, for the room of a new object, first resort to the existed pre-allocated block, if rest room in the block caters for the need, just use it, or else malloc a new big block for the need.
  见原出处
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值