{"id":13667912,"url":"https://github.com/claytonwramsey/dumpster","last_synced_at":"2025-04-26T18:30:47.245Z","repository":{"id":174791830,"uuid":"652417898","full_name":"claytonwramsey/dumpster","owner":"claytonwramsey","description":"Cycle-tracking garbage collector library for Rust","archived":false,"fork":false,"pushed_at":"2025-01-19T17:24:56.000Z","size":393,"stargazers_count":178,"open_issues_count":2,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T15:13:32.799Z","etag":null,"topics":["garbage-collection","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/dumpster","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/claytonwramsey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-12T03:14:50.000Z","updated_at":"2025-03-29T20:03:24.000Z","dependencies_parsed_at":"2024-01-14T16:14:43.093Z","dependency_job_id":"a4f6fdbe-bcfa-468b-910a-6ad7996b5585","html_url":"https://github.com/claytonwramsey/dumpster","commit_stats":null,"previous_names":["claytonwramsey/dumpster"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claytonwramsey%2Fdumpster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claytonwramsey%2Fdumpster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claytonwramsey%2Fdumpster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claytonwramsey%2Fdumpster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/claytonwramsey","download_url":"https://codeload.github.com/claytonwramsey/dumpster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251035149,"owners_count":21526309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["garbage-collection","rust"],"created_at":"2024-08-02T07:00:54.227Z","updated_at":"2025-04-26T18:30:47.239Z","avatar_url":"https://github.com/claytonwramsey.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# `dumpster`: A cycle-tracking garbage collector for Rust\n\n`dumpster` is an cycle-detecting garbage collector for Rust.\nIt detects unreachable allocations and automatically frees them.\n\n## Why should you use this crate?\n\nIn short, `dumpster` offers a great mix of usability, performance, and flexibility.\n\n- `dumpster`'s API is a drop-in replacement for `std`'s reference-counted shared allocations\n  (`Rc` and `Arc`).\n- It's very performant and has builtin implementations of both thread-local and concurrent\n  garbage collection.\n- There are no restrictions on the reference structure within a garbage-collected allocation\n  (references may point in any way you like).\n- It's trivial to make a custom type Trace using the provided derive macros.\n- You can even store `?Sized` data in a garbage-collected pointer!\n\n## How it works\n\n`dumpster` is unlike most tracing garbage collectors.\nOther GCs keep track of a set of roots, which can then be used to perform a sweep and find out\nwhich allocations are reachable and which are not.\nInstead, `dumpster` extends reference-counted garbage collection (such as `std::rc::Rc`) with a\ncycle-detection algorithm, enabling it to effectively clean up self-referential data structures.\n\nFor a deeper dive, check out this\n[blog post](https://claytonwramsey.github.io/2023/08/14/dumpster.html).\n\n## What this library contains\n\n`dumpster` actually contains two garbage collector implementations: one thread-local, non-`Send`\ngarbage collector in the module `unsync`, and one thread-safe garbage collector in the module\n`sync`.\nThese garbage collectors can be safely mixed and matched.\n\nThis library also comes with a derive macro for creating custom Trace types.\n\n## Examples\n\n```rust\nuse dumpster::{Trace, unsync::Gc};\n\n#[derive(Trace)]\nstruct Foo {\n    ptr: RefCell\u003cOption\u003cGc\u003cFoo\u003e\u003e\u003e,\n}\n\n// Create a new garbage-collected Foo.\nlet foo = Gc::new(Foo {\n    ptr: RefCell::new(None),\n});\n\n// Insert a circular reference inside of the foo.\n*foo.ptr.borrow_mut() = Some(foo.clone());\n\n// Render the foo inaccessible.\n// This may trigger a collection, but it's not guaranteed.\n// If we had used `Rc` instead of `Gc`, this would have caused a memory leak.\ndrop(foo);\n\n// Trigger a collection.\n// This isn't necessary, but it guarantees that `foo` will be collected immediately (instead of\n// later).\ndumpster::unsync::collect();\n```\n\n## Installation\n\nTo install, simply add `dumpster` as a dependency to your project.\n\n```toml\n[dependencies]\ndumpster = \"1.1.0\"\n```\n\n## Optional features\n\n## `derive`\n\n`derive` is enabled by default.\nIt enables the derive macro for `Trace`, which makes it easy for users to implement their\nown Trace types.\n\n```rust\nuse dumpster::{unsync::Gc, Trace};\nuse std::cell::RefCell;\n\n#[derive(Trace)] // no manual implementation required\nstruct Foo(RefCell\u003cOption\u003cGc\u003cFoo\u003e\u003e\u003e);\n\nlet my_foo = Gc::new(Foo(RefCell::new(None)));\n*my_foo.0.borrow_mut() = Some(my_foo.clone());\n\ndrop(my_foo); // my_foo will be automatically cleaned up\n```\n\n## `either`\n\n`either` is disabled by default. It adds support for the [`either`](https://crates.io/crates/either) crate,\nspecifically by implementing `Trace` for [`either::Either`](https://docs.rs/either/1.13.0/either/enum.Either.html).\n\n## `coerce-unsized`\n\n`coerce-unsized` is disabled by default.\nThis enables the implementation of `CoerceUnsized` for each garbage collector,\nmaking it possible to use `Gc` with `!Sized` types conveniently.\n\n```rust\nuse dumpster::unsync::Gc;\n\n// this only works with \"coerce-unsized\" enabled while compiling on nightly Rust\nlet gc1: Gc\u003c[u8]\u003e = Gc::new([1, 2, 3]);\n```\n\nTo use `coerce-unsized`, edit your installation to `Cargo.toml` to include the feature.\n\n```toml\n[dependencies]\ndumpster = { version = \"1.1.0\", features = [\"coerce-unsized\"]}\n```\n\n## License\n\nThis code is licensed under the Mozilla Public License, version 2.0.\nFor more information, refer to [LICENSE.md](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaytonwramsey%2Fdumpster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclaytonwramsey%2Fdumpster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaytonwramsey%2Fdumpster/lists"}