pub struct GC<T>where
T: GCTraceable<T> + 'static,{ /* private fields */ }
Implementations§
Source§impl<T> GC<T>where
T: GCTraceable<T> + 'static,
impl<T> GC<T>where
T: GCTraceable<T> + 'static,
Sourcepub fn new_with_percentage(percentage: usize) -> GC<T>
pub fn new_with_percentage(percentage: usize) -> GC<T>
创建一个新的垃圾回收器,指定回收触发的百分比
例如,new_with_percentage(30)
表示当attach次数超过当前对象数的30%时触发回收
Sourcepub fn new_with_memory_threshold(memory_threshold: usize) -> GC<T>
pub fn new_with_memory_threshold(memory_threshold: usize) -> GC<T>
创建一个新的垃圾回收器,指定内存阈值(字节) 当分配的内存超过指定阈值时触发回收
Sourcepub fn new_with_thresholds(percentage: usize, memory_threshold: usize) -> GC<T>
pub fn new_with_thresholds(percentage: usize, memory_threshold: usize) -> GC<T>
创建一个新的垃圾回收器,同时指定百分比阈值和内存阈值 任一条件满足时都会触发回收
pub fn attach(&mut self, gc_arc: &GCArc<T>)
pub fn detach(&mut self, gc_arc: &GCArc<T>) -> bool
pub fn collect(&mut self)
pub fn object_count(&self) -> usize
pub fn get_all(&self) -> Vec<GCArc<T>>
pub fn create(&mut self, obj: T) -> GCArc<T>
Sourcepub fn allocated_memory(&self) -> usize
pub fn allocated_memory(&self) -> usize
获取当前分配的内存估算值(字节)
Sourcepub fn set_memory_threshold(&mut self, threshold: Option<usize>)
pub fn set_memory_threshold(&mut self, threshold: Option<usize>)
设置内存阈值,None表示禁用内存阈值触发
Sourcepub fn memory_threshold(&self) -> Option<usize>
pub fn memory_threshold(&self) -> Option<usize>
获取当前内存阈值
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for GC<T>
impl<T> RefUnwindSafe for GC<T>
impl<T> Send for GC<T>
impl<T> Sync for GC<T>
impl<T> Unpin for GC<T>
impl<T> UnwindSafe for GC<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more