Get current memory statistics
(&self)
| 334 | |
| 335 | /// Get current memory statistics |
| 336 | pub fn get_stats(&self) -> MemoryStats { |
| 337 | let mut stats = self.stats.lock(); |
| 338 | |
| 339 | // Update stats from atomic counters |
| 340 | stats.buffer_pool_bytes = self.buffer_pool_bytes.load(Ordering::Relaxed); |
| 341 | stats.message_bytes = self.message_bytes.load(Ordering::Relaxed); |
| 342 | stats.query_bytes = self.query_bytes.load(Ordering::Relaxed); |
| 343 | stats.cleanup_events = self.cleanup_events.load(Ordering::Relaxed); |
| 344 | |
| 345 | // Update peak memory |
| 346 | let current_total = stats.total_bytes(); |
| 347 | if current_total > stats.peak_memory_bytes { |
| 348 | stats.peak_memory_bytes = current_total; |
| 349 | } |
| 350 | |
| 351 | // Update pressure level based on current memory usage |
| 352 | stats.pressure_level = self.calculate_pressure_level(current_total); |
| 353 | |
| 354 | stats.clone() |
| 355 | } |
| 356 | |
| 357 | /// Force a memory cleanup |
| 358 | pub fn force_cleanup(&self) { |