Skip to content

[QST] Using the pooled memory resource deallocate() method without specifying the number of bytes to free #1819

Answered by harrism
gartavanis asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately this is not possible. The design of memory resources is such that the allocate and deallocate calls must match. One reason for this is so that we can have things like binning allocators that delegate allocation to different suballocators depending on the size of the allocation. For efficiency, you might want to use a very different algorithm and/or pool to allocate very large regions of memory or very small allocations.

My advice is to avoid raw allocation (e.g. calls to allocate/deallocate, any form of malloc or new) altogether. All raw allocation should be done inside containers. Containers should always know their size and therefore always know how to pass the size. You c…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@gartavanis
Comment options

Answer selected by gartavanis
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #1818 on February 10, 2025 20:14.