diff --git a/crates/xserv-cuda/src/allocator.rs b/crates/xserv-cuda/src/allocator.rs index f007d22..3bd9e31 100644 --- a/crates/xserv-cuda/src/allocator.rs +++ b/crates/xserv-cuda/src/allocator.rs @@ -100,6 +100,13 @@ pub fn cached_alloc(size: usize) -> Result { }) } +/// Free all cached (unused) GPU buffers back to the driver. +pub fn cached_trim() { + ALLOCATOR.with(|cell| { + cell.borrow_mut().trim(); + }); +} + /// Return a raw GPU pointer to the caching allocator's free list. /// Called from `GpuBuffer::Drop` for pooled buffers. Takes raw pointer /// and size to avoid re-triggering Drop.