@@ -69,6 +69,11 @@ struct MemoryPoolStats {
6969 std::atomic<size_t > cache_hits{0 };
7070 std::atomic<size_t > cache_misses{0 };
7171
72+ // Delete copy constructor and assignment operator
73+ MemoryPoolStats () = default ;
74+ MemoryPoolStats (const MemoryPoolStats&) = delete ;
75+ MemoryPoolStats& operator =(const MemoryPoolStats&) = delete ;
76+
7277 double GetCacheHitRate () const {
7378 size_t total = cache_hits + cache_misses;
7479 return total > 0 ? static_cast <double >(cache_hits) / total : 0.0 ;
@@ -416,10 +421,17 @@ class MemoryPool {
416421 }
417422
418423 /* *
419- * @brief Get pool statistics
424+ * @brief Get pool statistics (returns a snapshot copy)
420425 */
421- MemoryPoolStats GetStats () const {
422- return stats_;
426+ void GetStats (MemoryPoolStats& out_stats) const {
427+ out_stats.total_allocated .store (stats_.total_allocated .load ());
428+ out_stats.total_freed .store (stats_.total_freed .load ());
429+ out_stats.current_usage .store (stats_.current_usage .load ());
430+ out_stats.peak_usage .store (stats_.peak_usage .load ());
431+ out_stats.allocation_count .store (stats_.allocation_count .load ());
432+ out_stats.free_count .store (stats_.free_count .load ());
433+ out_stats.cache_hits .store (stats_.cache_hits .load ());
434+ out_stats.cache_misses .store (stats_.cache_misses .load ());
423435 }
424436
425437 /* *
@@ -437,8 +449,15 @@ class MemoryPool {
437449 // Clear large allocations
438450 large_allocations_.clear ();
439451
440- // Reset stats
441- stats_ = MemoryPoolStats ();
452+ // Reset stats (manually reset each atomic)
453+ stats_.total_allocated .store (0 );
454+ stats_.total_freed .store (0 );
455+ stats_.current_usage .store (0 );
456+ stats_.peak_usage .store (0 );
457+ stats_.allocation_count .store (0 );
458+ stats_.free_count .store (0 );
459+ stats_.cache_hits .store (0 );
460+ stats_.cache_misses .store (0 );
442461
443462 // Reinitialize if needed
444463 if (initialized_) {
@@ -601,7 +620,7 @@ class MemoryPool {
601620 std::unordered_map<std::thread::id, std::unique_ptr<ThreadCache>> thread_caches_;
602621
603622 MemoryPoolStats stats_;
604- Logger logger_;
623+ engine:: Logger logger_;
605624};
606625
607626/* *
0 commit comments