From bb137da6f8b8caaad8f63bf264150aa5ae911837 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 11:55:50 -0500 Subject: [PATCH] xo-interpreter2 stack: cleanup memory reporting --- include/xo/facet/FacetRegistry.hpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/include/xo/facet/FacetRegistry.hpp b/include/xo/facet/FacetRegistry.hpp index da3a667..ad19cf5 100644 --- a/include/xo/facet/FacetRegistry.hpp +++ b/include/xo/facet/FacetRegistry.hpp @@ -10,6 +10,7 @@ #include "facet_implementation.hpp" #include "typeseq.hpp" #include "obj.hpp" +#include #include #include #include @@ -38,6 +39,7 @@ namespace xo { **/ class FacetRegistry { public: + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using typeseq = xo::reflect::typeseq; using key_type = std::pair; @@ -51,9 +53,12 @@ namespace xo { } }; - /** singleton instance **/ - static FacetRegistry & instance() { - static FacetRegistry s_instance; + /** singleton instance. + * @p hint_max_capacity is a lower bound for swiss hash map implementation. + * Only honored the first time instance is called. + **/ + static FacetRegistry & instance(uint32_t hint_max_capacity = 1024) { + static FacetRegistry s_instance(hint_max_capacity); return s_instance; } @@ -88,6 +93,11 @@ namespace xo { /** Number of registered (facet, repr) pairs **/ std::size_t size() const { return registry_.size(); } + /** visit memory pools owned by facet registry **/ + void visit_pools(const MemorySizeVisitor & visitor) { + registry_.visit_pools(visitor); + } + /** Check if implementation is registered **/ bool contains(typeseq facet_id, typeseq repr_id) const @@ -221,10 +231,12 @@ namespace xo { } private: - FacetRegistry() = default; + FacetRegistry(uint32_t hint_max_capacity) + : registry_("facets", hint_max_capacity, false /*!debug_flag*/) {} /** runtime lookup table (AFacet,DRepr) -> impl **/ - std::unordered_map registry_; + xo::map::DArenaHashMap registry_; + //std::unordered_map registry_; }; } /*namespace facet*/