memory-pool

Custom allocation using boost singleton_pool slower than default

六月ゝ 毕业季﹏ 提交于 2019-12-23 09:56:37
问题 I wrote custom operator new and operator delete for the class MyOrder. I am allocating memory using boost::singleton pool. Here is the program testing the performance, #include <boost/pool/singleton_pool.hpp> #include <boost/progress.hpp> #include <iostream> #include <new> #include <vector> class MyOrder{ std::vector<int> v1_; std::vector<double> v2_; std::string s1_; std::string s2_; public: MyOrder(std::string s1, std::string s2): s1_(s1), s2_(s2) {} ~MyOrder(){} static void * operator new

Generic Memory Pool - How to? - Design Issue

爱⌒轻易说出口 提交于 2019-12-11 02:25:09
问题 I am creating my own memory pool for small and very frequently used objects. I am good with the allocation and d-allocation itself. Here is layout of my Pool class CPool { unsigned int m_uiBlocks; unsigned int m_uiSizeOfBlock; unsigned int m_uiFreeBlocks; unsigned int m_uiInitialized; unsigned char *m_pMemStart; unsigned char *m_pNext; public: CPool(); ~CPool(); void CreatePool(size_t sizeOfEachBlock, unsigned int numOfBlocks); void DestroyPool(); unsigned char* AddrFromIndex(unsigned int i)

Designing and coding a non-fragmentizing static memory pool

谁都会走 提交于 2019-12-06 12:40:16
问题 I have heard the term before and I would like to know how to design and code one. Should I use the STL allocator if available? How can it be done on devices with no OS? What are the tradeoffs between using it and using the regular compiler implemented malloc/new? 回答1: Will try to describe what is essentially a memory pool - I'm just typing this off the top of my head, been a while since I've implemented one, if something is obviously stupid, it's just a suggestion! :) 1. To reduce

C++11 memory pool design pattern?

柔情痞子 提交于 2019-11-28 03:34:32
I have a program that contains a processing phase that needs to use a bunch of different object instances (all allocated on the heap) from a tree of polymorphic types, all eventually derived from a common base class. As the instances may cyclically reference each other, and do not have a clear owner, I want allocated them with new , handle them with raw pointers, and leave them in memory for the phase (even if they become unreferenced), and then after the phase of the program that uses these instances, I want to delete them all at once. How I thought to structure it is as follows: struct B; //

What does posix_memalign/memalign do

一曲冷凌霜 提交于 2019-11-27 17:03:25
I'm trying to understand what functions memalign() and posix_memalign() do. Reading the available documentation didn't help. Can someone help me understand how it works and what is it used for? Or, perhaps provide a usage example? I'm trying to understand how linux memory works, I need to write my own simple memory pool (low-fragmentation heap). Whereas malloc gives you a chunk of memory that could have any alignment (the only requirement is that it must be aligned for the largest primitive type that the implementation supports), posix_memalign gives you a chunk of memory that is guaranteed to

C++11 memory pool design pattern?

前提是你 提交于 2019-11-27 05:10:35
问题 I have a program that contains a processing phase that needs to use a bunch of different object instances (all allocated on the heap) from a tree of polymorphic types, all eventually derived from a common base class. As the instances may cyclically reference each other, and do not have a clear owner, I want allocated them with new , handle them with raw pointers, and leave them in memory for the phase (even if they become unreferenced), and then after the phase of the program that uses these

What does posix_memalign/memalign do

喜欢而已 提交于 2019-11-26 18:54:08
问题 I'm trying to understand what functions memalign() and posix_memalign() do. Reading the available documentation didn't help. Can someone help me understand how it works and what is it used for? Or, perhaps provide a usage example? I'm trying to understand how linux memory works, I need to write my own simple memory pool (low-fragmentation heap). 回答1: Whereas malloc gives you a chunk of memory that could have any alignment (the only requirement is that it must be aligned for the largest