寻找开源内存池 [英] Looking for an open source memory pool

查看:76
本文介绍了寻找开源内存池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在寻找一个开源内存池。它适用于

嵌入式系统,如果这有任何区别的话。有垃圾的东西

收集/碎片整理会很好。它应该具有分配不同大小的内存块而不仅仅是单个大小的能力。它应该是错误检查双重免费等等。它应该可以由一个C和C ++子系统的混合使用。


如果我明白了,我很高兴。非常感谢。


作为奖励,我想检测一下内存泄漏,虽然我愿意给我自己的b $ b代码得到我想要的东西(我只是不想重新发明

标准内存池的轮子)。


我看到两种检测方法泄漏。两者都涉及内存池

实际分配的内存比请求的多,并为自己保留一个

的秘密标题,它存储调用者的详细信息(文件/

行号或唯一ID,加上时间戳)。


在每次单元测试后,我通常会将任何分配的内存释放到

,所以comapring测试开始和结束时的内存池免费大小

应该足够了。如果我知道测试会导致我的软件分配但不能释放一些内存,我可以调整一下(对于

实例,软件测试分配缓冲区到发送消息

将被收件人,计时器数据块或类似物释放。


单元测试这么多,应该是直截了当。整合

&系统验证测试更复杂,有很多后台运行的b
任务。但是,在嵌入式系统中,

内存保持长时间分配是不常见的。所以我可以创建一个低优先级的

任务,该任务在系统处于空闲状态时运行,并检查

时间戳,寻找分配给可疑长时间的内存

time",然后可以调查,看看有人忘了免费

吧。不完美,但还不够好。


有何评论?还有任何基本的开源内存池,我可以使用

作为基础吗?


提前谢谢...

解决方案

7月25日,9:34 * am,graham.keelli ... @ gmail.com写道:





*我正在寻找一个开源内存池。它适用于

嵌入式系统,如果这有任何区别的话。有垃圾的东西

收集/碎片整理会很好。它应该具有分配不同大小的内存块而不仅仅是单个大小的能力。它应该是错误检查双重免费等等。它应该可以由一个C和C ++子系统的混合使用。


如果我明白了,我很高兴。非常感谢。


作为奖励,我想检测一下内存泄漏,虽然我愿意给我自己的b $ b代码得到我想要的东西(我只是不想重新发明

标准内存池的轮子)。


我看到两种检测方法泄漏。两者都涉及内存池

实际分配的内存比请求的多,并为自己保留一个

的秘密标题,它存储调用者的详细信息(文件/

行号或唯一ID,加上时间戳)。


在每次单元测试后,我通常会将任何分配的内存释放到

,所以comapring测试开始和结束时的内存池免费大小

应该足够了。如果我知道测试会导致我的软件分配但不能释放一些内存,我可以调整一下(对于

实例,软件测试分配缓冲区到发送消息

将被收件人,计时器数据块或类似物释放。


单元测试这么多,应该是直截了当。整合

&系统验证测试更复杂,有很多后台运行的b
任务。但是,在嵌入式系统中,

内存保持长时间分配是不常见的。所以我可以创建一个低优先级的

任务,该任务在系统处于空闲状态时运行,并检查

时间戳,寻找分配给可疑长时间的内存

time",然后可以调查,看看有人忘了免费

吧。不完美,但还不够好。


有何评论?还有任何基本的开源内存池,我可以使用

作为基础吗?


提前谢谢...


Bosst ++看起来不错。请参阅
http ://www.boost.org/doc/libs/1_35_0...d_storage.html


gr ************** @ gmail.com 写道:


垃圾收集/碎片整理的东西会很好。


作为奖励,我想检测内存泄漏



Aren这两件事有点互相排斥吗?


On 2008-07-25 10:02:43 -0400,Juha Nieminen< no **** @ thanks.invalidsaid:

gr ***** *********@gmail.com 写道:


>垃圾收集/碎片整理的东西会很好。


>作为奖励,我想检测内存泄漏



这两件事有点相互排斥吗?



编号当应用程序终止时,所有可到达的内存都已泄露。


-

Pete

Roundhouse Consulting,Ltd。( www.versatilecoding.com )作者

标准C ++库扩展:教程和参考
www.petebecker.com/tr1book )


hi,

I''m looking for an open source memory pool. It''s for use on an
embedded system, if that makes any difference. Something with garbage
collection/defragmentation would be nice. It should have the ability
to allocate different size chunks of memory not just a single size. It
should error check for double free, etc. And it should be usable by a
mixture of C and C++ subsystems.

If I get that, I''m happy. Thank you very much.

As a bonus, I''d like to detect memory leaks, although I''m willing to
code that bit myself to get what I want (I just don''t want to reinvent
the wheel of a standard memory pool).

I see two approaches to detecting leaks. Both involve the memory pool
actually allocating more memory than was requested and keeping a
secret header for itself where it stores details of the caller (file/
line number or unique ID, plus timestamp).

After each unit test I would generally expect any allocated memory to
be freed, so comapring memory pool free size at start and end of test
should suffice. If I know that the test will cause my software to
allocate but not free some memory, I can adjust for that (for
instance, Software Under Test allocates a buffer to send a message
which will be freed by recipient, or a timer data block, or similar).

So much for unit test, which ought to be straightforward. Integration
& system verification test are more complex, with lots of background
tasks running. However, in an embedded system it is uncommon for
memory to remain allocated for long. So I can create a low priority
task which runs when the system is otherwise idle and checks
timestamps, looking for memory allocated for "a suspiciously long
time", which can then be investigated to see if someone forgot to free
it. Not perfect, but more than good enough.

Any comments? And any basic, Open Source, memory pool which I can use
as a base?

Thanks in advance...

解决方案

On Jul 25, 9:34*am, graham.keelli...@gmail.com wrote:

hi,

* I''m looking for an open source memory pool. It''s for use on an
embedded system, if that makes any difference. Something with garbage
collection/defragmentation would be nice. It should have the ability
to allocate different size chunks of memory not just a single size. It
should error check for double free, etc. And it should be usable by a
mixture of C and C++ subsystems.

If I get that, I''m happy. Thank you very much.

As a bonus, I''d like to detect memory leaks, although I''m willing to
code that bit myself to get what I want (I just don''t want to reinvent
the wheel of a standard memory pool).

I see two approaches to detecting leaks. Both involve the memory pool
actually allocating more memory than was requested and keeping a
secret header for itself where it stores details of the caller (file/
line number or unique ID, plus timestamp).

After each unit test I would generally expect any allocated memory to
be freed, so comapring memory pool free size at start and end of test
should suffice. If I know that the test will cause my software to
allocate but not free some memory, I can adjust for that (for
instance, Software Under Test allocates a buffer to send a message
which will be freed by recipient, or a timer data block, or similar).

So much for unit test, which ought to be straightforward. Integration
& system verification test are more complex, with lots of background
tasks running. However, in an embedded system it is uncommon for
memory to remain allocated for long. So I can create a low priority
task which runs when the system is otherwise idle and checks
timestamps, looking for memory allocated for "a suspiciously long
time", which can then be investigated to see if someone forgot to free
it. Not perfect, but more than good enough.

Any comments? And any basic, Open Source, memory pool which I can use
as a base?

Thanks in advance...

Bosst++ is looking good. See
http://www.boost.org/doc/libs/1_35_0...d_storage.html


gr**************@gmail.com wrote:

Something with garbage collection/defragmentation would be nice.

As a bonus, I''d like to detect memory leaks

Aren''t those two things a bit mutually exclusive?


On 2008-07-25 10:02:43 -0400, Juha Nieminen <no****@thanks.invalidsaid:

gr**************@gmail.com wrote:

>Something with garbage collection/defragmentation would be nice.

>As a bonus, I''d like to detect memory leaks


Aren''t those two things a bit mutually exclusive?

No. When the application terminates, all reachable memory has been leaked.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)


这篇关于寻找开源内存池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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