Skip to content

Support C++17 polymorphic memory resources

Describe the feature you would like to be implemented.

Dynamically allocated storage types (like MatrixX[fd] and VectorX[fd]) should be able to allocate their memory using a polymorphic allocator. This would allow their use with different allocation strategies.

Would such a feature be useful for other users? Why?

Polymorphic memory resources allow us to easily implement allocators such as stack, pool, and arena allocators. This can greatly improve performance. For example, if the user knows that a small, dynamically allocated matrix will never exceed some (compile-time known) size, one can use std::pmr::monotonic_buffer_resource to keep the matrix on the stack and never need a call to malloc()/free().

Any hints on how to implement the requested feature?

See:

Additional resources

See also: #166 #789 #1568 #1963 (closed)

Edited by Patrick Fasano