tlsf memory allocator implementation
(two level segregated fit) is a relatively new memory
allocator designed for embedded systems. It boasts constant
time O(1) malloc/free response time and a 4-byte block
overhead. Though it typically is slightly slower than other
allocators such as dlmalloc,
it has no worst-case behavior.
The original implementation, which comes alongside the white
paper, is distributed under the GNU GPL/LGPL. The code found
here is an original implementation, released into the public
domain, therefore is not subject to any licensing restrictions.
cost for malloc, free, realloc, memalign
low overhead per allocation (4 bytes)
overhead per pool (~3kB)
to only a few kB of code and data
- Currently, assumes architecture can make 4-byte aligned
- Not designed to be thread safe; the user must provide this
Due to the internal block structure size and the implementation
details of tlsf_memalign, there is worst-case behavior when requesting
small (<16 byte) blocks aligned to 8-byte boundaries. Overuse of
will generally increase fragmentation, but this particular case will
lots of unusable "holes" in the heap. The solution would be to
align all blocks to 8 bytes, but this will require significantl changes
to the implementation. Contact me if you are interested.