如何使用 Loki 的小对象分配器?
我需要使用 Loki 的小对象分配器,但我对其工作原理感到非常困惑。我已经阅读了文档和很多论坛,但没有意义:其中一些人说使用 stl,其他人则使用自定义分配器。我只需要能够通过分配和取消分配不同大小的对象来测试其性能。有人可以提供一个如何使用它的小例子吗?
I need to use Loki's small object allocator but I am very confused as to how it works. I've read the documentation and lots of forums but it doesnt make sense: some of them say to use the stl, others use custom allocators. I just need to be able to test its performance with allocating and deallocating objects of different sizes. Could someone please provide a small example of how to use it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你访问 Loki 项目,你可能不想使用 SmallObject。它的运行速度比默认的 new 慢。我不知道为什么,但有些人在这里讨论了:
http://sourceforge.net/projects/loki-lib/forums /forum/93009/topic/3828398
If you visit the Loki project,you might don't want to use SmallObject.It runs slower than default new.I don't know why,but some guys talked here:
http://sourceforge.net/projects/loki-lib/forums/forum/93009/topic/3828398
好吧,我得到的最好结果就是让 Loki 的小对象分配器符合 STL。为此,我刚刚根据 http://www.codeproject.com/kb/cpp/allocator.aspx?fid=16541&df=90&mpp=25&sort=Position& ;tid=1677312
Ok, best I got was to make Loki's Small Object Allocator compliant with the STL. To do this I just created a wrapper class for the SmallObjAllocator class in Loki according to http://www.codeproject.com/kb/cpp/allocator.aspx?fid=16541&df=90&mpp=25&sort=Position&tid=1677312