MCPcopy Create free account
hub / github.com/erans/pgsqlite / trigger_cleanup

Method trigger_cleanup

src/protocol/memory_monitor.rs:255–289  ·  view source on GitHub ↗

Trigger cleanup based on memory pressure

(&self, pressure: MemoryPressure)

Source from the content-addressed store, hash-verified

253
254 /// Trigger cleanup based on memory pressure
255 fn trigger_cleanup(&self, pressure: MemoryPressure) {
256 let mut last_check = self.last_check.lock();
257
258 // Rate limit cleanup events
259 if last_check.elapsed() < self.config.check_interval {
260 return;
261 }
262
263 *last_check = Instant::now();
264
265 // Increment cleanup counter
266 self.cleanup_events.fetch_add(1, Ordering::Relaxed);
267
268 // Update stats
269 {
270 let mut stats = self.stats.lock();
271 stats.last_cleanup = Some(Instant::now());
272 }
273
274 match pressure {
275 MemoryPressure::Medium => {
276 debug!("Medium memory pressure detected, triggering gentle cleanup");
277 self.execute_cleanup_callbacks(false);
278 }
279 MemoryPressure::High => {
280 info!("High memory pressure detected, triggering cleanup");
281 self.execute_cleanup_callbacks(false);
282 }
283 MemoryPressure::Critical => {
284 warn!("Critical memory pressure detected, triggering aggressive cleanup");
285 self.execute_cleanup_callbacks(true);
286 }
287 MemoryPressure::Low => {}
288 }
289 }
290
291 /// Execute registered cleanup callbacks
292 fn execute_cleanup_callbacks(&self, aggressive: bool) {

Callers 1

check_memory_pressureMethod · 0.80

Calls 1

Tested by

no test coverage detected