cabbage_collector

Crates.iocabbage_collector
lib.rscabbage_collector
version
sourcesrc
created_at2025-04-13 16:20:42.889059+00
updated_at2025-04-20 17:32:26.51465+00
descriptionready
homepagehttps://github.com/myyrakle/cabbage_collector/blob/master/README.md
repositoryhttps://github.com/myyrakle/cabbage_collector
max_upload_size
id1631957
Cargo.toml error:TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
myyrakle (myyrakle)

documentation

https://github.com/myyrakle/cabbage_collector/blob/master/README.md

README

Cabbage Collector

  • Simple GC implementation
  • Simple Mark and Sweep

Guide

The way to create and use the object is almost the same as Box<T>. However, in the current implementation, GC must be triggered manually.

    {
        #[derive(Debug, Clone)]
        struct A {
            pub value: i32,
        }

        let child_obj = CabbageBox::new(A { value: 1 });
        println!("{:?}", child_obj);
    }
    COLLECTOR.run_cabbage_collection();

The circular reference issue has been resolved.

    {
        #[derive(Debug, Clone)]
        struct A {
            pub value: Option<CabbageBox<B>>,
        }

        #[derive(Debug, Clone)]
        struct B {
            pub value: Option<CabbageBox<A>>,
        }

        let mut a_obj = CabbageBox::new(A { value: None });
        let mut b_obj = CabbageBox::new(B { value: None });

        a_obj.value = Some(b_obj.clone());
        b_obj.value = Some(a_obj.clone());
    }
    COLLECTOR.run_cabbage_collection();

Checklist

  • Circular Reference
  • Automatically identifies root and non-root
  • Auth trigger GC
  • Concurrent GC
  • Generational GC
  • Memory Compaction
Commit count: 0

cargo fmt