Memory pooling
Memory pooling
My program does a lot of on-the-fly memory allocations: small amounts of memory (< 128 bytes) constantly get allocated and freed. I was wondering if using a memory pool would be more considerate of the memory system, especially as regards fragmentation.
The Rear Window blog
AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
- LyleHaze
- AmigaOS Core Developer
- Posts: 525
- Joined: Sat Jun 18, 2011 5:06 pm
- Location: North Florida, near the Big Bend
Re: Memory pooling
Yes.
It also provides a simple way to free the entire pool if desired.
If your "small amounts of memory" are all the same size, you might also consider an ItemPool (ASOT_ITEMPOOL) instead of MemoryPool(ASOT_MEMPOOL), which can optimize for many same-sized allocations.
It also provides a simple way to free the entire pool if desired.
If your "small amounts of memory" are all the same size, you might also consider an ItemPool (ASOT_ITEMPOOL) instead of MemoryPool(ASOT_MEMPOOL), which can optimize for many same-sized allocations.
- Hans
- AmigaOS Core Developer
- Posts: 703
- Joined: Tue Dec 21, 2010 9:25 pm
- Location: New Zealand
- Contact:
Re: Memory pooling
Are these items all of the same size? If so, please use item pools instead. They're designed especially for the frequent allocation and deallocation of small blocks that are all the same size.trixie wrote:My program does a lot of on-the-fly memory allocations: small amounts of memory (< 128 bytes) constantly get allocated and freed. I was wondering if using a memory pool would be more considerate of the memory system, especially as regards fragmentation.
Look up ASOT_ITEMPOOL, ItemPoolAlloc()/ItemPoolFree() in the Exec autodocs.
Hans
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. Home of the RadeonHD driver for Amiga OS 4.x project.
Re: Memory pooling
Thank you both!
The Rear Window blog
AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition