Function rug::float::free_cache

source ·
pub fn free_cache(which: FreeCache)
Expand description

Frees various caches and memory pools that are used internally.

To avoid memory leaks being reported when using tools like Valgrind, it is advisable to free thread-local caches before terminating a thread and all caches before exiting.

§Examples

use rug::float;
use rug::float::FreeCache;
use std::thread;

fn main() {
    let child = thread::spawn(move || {
        // some work here that uses Float
        float::free_cache(FreeCache::Local);
    });
    // some work here
    child.join().expect("couldn't join thread");
    float::free_cache(FreeCache::All);
}