
Ion GaztaƱaga wrote:
Hi Chris,
I made a few quick changes and re-ran the daytime3 server to observe the memory allocations. What I changed was:
<some code>
Looks good. Eliminating "null()" makes things much better. However the underlying shared_ptr<socket> is quite important. Until you find a better solution, you could try to use a simple segregated storage (boost::pool or similar) for socket allocation to minimize memory use (in 32 systems unsigned int has the same size as a pointer) and the user could define BOOST_SP_USE_QUICK_ALLOCATOR so that shared_ptr's shared_count objects are also pooled. This way, memory waste will be minimum and the allocation very fast.
If ::operator new isn't terribly broken (if it is, use dlmalloc), memory waste will aready be minimal and allocation would already be fast for small objects. Custom per-component allocators are rarely worth the trouble, and should never be the default.