lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 04.04.2011 15:03, C++ RTMP Server wrote:
I have done extensive tests with mem allocations and the things are looking pretty ugly when allocating/deallocating mem which is not PAGE_SIZE aligned. When one requests 564 bytes for example, the allocator will alloc PAGE_SIZE increments anyway (which is usually 4096 bytes). So is a total waste of resources NOT to use that buffer in the future: just make it PAGE_SIZE and re-use it when the time comes. Even with this little optimization the things are looking far brighter.

I'll never believe that the default allocator doesn't reuse this buffer.

I totally agree: sometimes the compiler can do wonders and the app runs much smoother without mempool. But that can be experimented and the mempool can be (de)activated at compile time depending on the target platform used.

What I learned so far, is that solely relaying on the mem allocator and abuse it thinking that will cope with all the possible situations, is a very bad practice. mem alocators are not gods :)

Mempool is just another mem allocator, isn't it? Or rather just one of approaches used by mem allocators. For example, http://goog-perftools.sourceforge.net/doc/tcmalloc.html basically uses this approach as I understand.

As for Lua, it has very few statically-sized structures, meaning they can be efficiently allocated with exact size. Vectors are usually grown by multiplying size by 2, which may or may not be of use for memory allocator. However, for the most part I guess Lua is a pretty ordinary 'client' of mem allocator.

P.S. I'm also new to the subject.

--
Best regards,
Sergey Rozhenko                 mailto:sergroj@mail.ru