由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Dynamic buffer management question
相关主题
why do we still use dynamic allocation?What problem can occur when dynamically allocated classes
内存分配问题请问一个入门级 dynamic memory 的问题
a small question about c++ memory allocation【请教】在家里用2个router上网(一前一后)的问题 (转载)
char[] 和 char*有什么区别?3 c++ challenge-and-grill questions
哪位在Linux上用C++碰到过memory fragmentation吗?new一定要和delete配对吗?
Please Help, dynamic memory after fork()[合集] 问个题--- web dynamic graphic generation
static variable存在heap还是stack?backend language of choice
vector< vector > > 怎么初始化?linux内存分配中page的几个问题
相关话题的讨论汇总
话题: buffer话题: dynamic话题: callers话题: so话题: my
进入Programming版参与讨论
1 (共1页)
s*v
发帖数: 3
1
I'm looking for the best possible solution to this problem:
My class maintains a dynamic buffer that outside callers can write into.
Callers may write in anything with any size. So my buffer has to grow
dynamically. What's the best way to maintain this buffer so that heap
allocation cost is minimized?
Or: a completely different implementation strategy/thinking recommendation
is
also welcome.
Thanks.
h****e
发帖数: 2125
2
use a linked list, each node has a address pointing to the start of big
chunk of contiguous memory of size N. Whenever it needs to grow, just
allocate another chunk of memory of size N and append a new node having the
starting address to the linked list.

【在 s*v 的大作中提到】
: I'm looking for the best possible solution to this problem:
: My class maintains a dynamic buffer that outside callers can write into.
: Callers may write in anything with any size. So my buffer has to grow
: dynamically. What's the best way to maintain this buffer so that heap
: allocation cost is minimized?
: Or: a completely different implementation strategy/thinking recommendation
: is
: also welcome.
: Thanks.

b******n
发帖数: 592
3
but writing anything of any size ...

the

【在 h****e 的大作中提到】
: use a linked list, each node has a address pointing to the start of big
: chunk of contiguous memory of size N. Whenever it needs to grow, just
: allocate another chunk of memory of size N and append a new node having the
: starting address to the linked list.

T*****9
发帖数: 2484
4
google pintos project 0,please!

【在 s*v 的大作中提到】
: I'm looking for the best possible solution to this problem:
: My class maintains a dynamic buffer that outside callers can write into.
: Callers may write in anything with any size. So my buffer has to grow
: dynamically. What's the best way to maintain this buffer so that heap
: allocation cost is minimized?
: Or: a completely different implementation strategy/thinking recommendation
: is
: also welcome.
: Thanks.

1 (共1页)
进入Programming版参与讨论
相关主题
linux内存分配中page的几个问题哪位在Linux上用C++碰到过memory fragmentation吗?
怎样高效管理内存?Please Help, dynamic memory after fork()
菜鸟请教C问题static variable存在heap还是stack?
coding就是行为艺术--Try Julia (2)vector< vector > > 怎么初始化?
why do we still use dynamic allocation?What problem can occur when dynamically allocated classes
内存分配问题请问一个入门级 dynamic memory 的问题
a small question about c++ memory allocation【请教】在家里用2个router上网(一前一后)的问题 (转载)
char[] 和 char*有什么区别?3 c++ challenge-and-grill questions
相关话题的讨论汇总
话题: buffer话题: dynamic话题: callers话题: so话题: my