I am learning the memory pool by reading Nginx-related source code. In Nginx memory pool implementation, has ngx_pfree(), but it's for large data blocks only, so small memory chunks aren't freeable until the memory pool itself has been destroyed ngx_destroy_pool().
By using API ngx_reset_pool() , all the small memory chunks will be reset but can not reset the small piece of memory the application applies from within the small chunk. I can imagine that with time, there will be plenty of the small pieces of memory space within each pre-allocated memory chunk that will not used and will stay there until the reset of the destruction of the memory pool. And it might be a huge waste of allocated memory space.
I also read some other memory pool implementations that will provide the API to just reset that piece of memory space within the pre-allocated memory chuck with complicated address pointer operations, very time-consuming.
For the Nginx memory pool, is this a good design example for a memory pool? Again, I am new to the memory pool, any advice or ideas are helpful. Thanks in advance.