4 ms·
Common practice if you're doing a large number of very small allocations is to pre-allocate a larger area of memory for them, then use a more naive allocation a
by ekimekim 11y ago
Common practice if you're doing a large number of very small allocations is to pre-allocate a larger area of memory for them, then use a more naive allocation algorithm to parcel it out.
- TheLoneWolfling 11y agoDefine "more naive allocation algorithm".
- eutectic 11y agoWhat about bump-pointer + maintaining a count of live allocations?
- TheLoneWolfling 11y agoThat won't work if you ever want to deallocate things - which, given that due to the compressed arrays you have to deallocate to add elements (deallocate the old array with <0,1,2,3> elements, allocate a new with <1,2,3,4> elements), won't work for this.
- eutectic 11y agoYou can deallocate if you use small enough chunks, although you might need to use some other strategies to minimize fragmentation.
- TheLoneWolfling 11y agoIf you're using "small enough chunks" your space overhead balloons to the point where you may as well not use it.