Boost logo

Boost Users :

From: Berenguer Blasi (bblasi_at_[hidden])
Date: 2006-08-07 10:38:36


Thanks!

Great explanation.

-----Mensaje original-----
De: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]]En nombre de Ion Gaztanaga
Enviado el: lunes, 07 de agosto de 2006 14:37
Para: Boost User List
Asunto: Re: [Boost-users] [shmem] Allocation of little objects

Hi Berenguer,

> If you do segment.allocate(3) many times you end up NOT using 100% of
> the available space but MUCH less.

Every dynamic allocatio needs to store deallocation information to know
the size of the buffer, perform buffer merging, etc... Apart from that,
an allocation has normally to fulfill some alignment constraints. In the
default Shmem allocation algorithm, 8 bytes are used per allocation to
store that information and the alignment is 8 bytes.

This means that when you want to allocate 3 bytes, you need to use 16
bytes of memory. That's why you run out of memory. Remember that the
initial size or the segment will never be fully used: depends on the
number of allocation and the size of that allocation. This is exactly
the same that happens with "operator new": you waste much more memory
with many small allocations than with a few big ones.

Regards,

Ion

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net