Skip to content

Comments

Introduce common::memory#3957

Draft
schnellerhase wants to merge 16 commits intomainfrom
schnellerhase/memory
Draft

Introduce common::memory#3957
schnellerhase wants to merge 16 commits intomainfrom
schnellerhase/memory

Conversation

@schnellerhase
Copy link
Contributor

@schnellerhase schnellerhase commented Oct 19, 2025

Introduces free function common::memory. Which provides a unit based access (in B, KB, MB, ...) to the implementation detail common::impl::memory, which computes for given types the used memory in bytes. This needs to be implemented for every type of which one wants to have access to a memory consumption (and its member types!).

This provides a user controllable memory profiling capability, up to a desired/required precision.

First step towards #1741.

TODO:

@schnellerhase
Copy link
Contributor Author

schnellerhase commented Oct 19, 2025

This is not yet ready for a proper review, but before extending the interface to more heavy types I wanted to check if this was the right way to go about implementing this interface or if this approach misses some important capabilities we would like to see.

In particular the python side is still very rough, and something along the lines of https://github.com/timlnx/bitmath/, would be very desirable.

@schnellerhase schnellerhase requested a review from jhale October 19, 2025 20:21
@schnellerhase schnellerhase added the enhancement New feature or request label Oct 19, 2025
@garth-wells
Copy link
Member

Looks like more-or-less the right direction to me.

We should consider how pedantic we want to be, e.g. for a large mesh the memory used by the Basix element will be trivial and do we really care about this. Do we want the truest possible measure of the memory used by an object, or just the storage memory used for parts that depend on problem size?

@jhale
Copy link
Member

jhale commented Feb 22, 2026

My understanding is that C++26 reflections could remove a lot of tedious boiler plate required to implement something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants