{"id":13838486,"url":"https://github.com/zesterer/broom","last_synced_at":"2025-10-04T05:44:47.095Z","repository":{"id":62438541,"uuid":"249490224","full_name":"zesterer/broom","owner":"zesterer","description":"An ergonomic tracing garbage collector that supports mark 'n sweep garbage collection","archived":false,"fork":false,"pushed_at":"2022-10-23T01:06:50.000Z","size":40,"stargazers_count":251,"open_issues_count":5,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-20T21:08:43.443Z","etag":null,"topics":["garbage-collector","memory-management","rust-lang"],"latest_commit_sha":null,"homepage":"https://docs.rs/broom/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zesterer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-23T16:53:11.000Z","updated_at":"2024-09-09T19:23:42.000Z","dependencies_parsed_at":"2022-11-01T22:01:30.385Z","dependency_job_id":null,"html_url":"https://github.com/zesterer/broom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fbroom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fbroom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fbroom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fbroom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zesterer","download_url":"https://codeload.github.com/zesterer/broom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"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-collector","memory-management","rust-lang"],"created_at":"2024-08-04T15:01:59.355Z","updated_at":"2025-10-04T05:44:42.061Z","avatar_url":"https://github.com/zesterer.png","language":"Rust","readme":"# Broom\n\nAn ergonomic tracing garbage collector that supports mark 'n sweep garbage collection.\n\n[![Cargo](https://img.shields.io/crates/v/broom.svg)](\nhttps://crates.io/crates/broom)\n[![Documentation](https://docs.rs/broom/badge.svg)](\nhttps://docs.rs/broom)\n[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](\nhttps://github.com/zesterer/broom)\n\n## Features\n\n- Ergonomic API\n- Mark and sweep heap cleaning\n- Easy (and safe) mutation of heap values, despite cycles\n- Zero-cost access to heap objects through handles\n\n## Example\n\n```rust\nuse broom::prelude::*;\n\n// The type you want the heap to contain\npub enum Object {\n    Num(f64),\n    List(Vec\u003cHandle\u003cSelf\u003e\u003e),\n}\n\n// Tell the garbage collector how to explore a graph of this object\nimpl Trace\u003cSelf\u003e for Object {\n    fn trace(\u0026self, tracer: \u0026mut Tracer\u003cSelf\u003e) {\n        match self {\n            Object::Num(_) =\u003e {},\n            Object::List(objects) =\u003e objects.trace(tracer),\n        }\n    }\n}\n\n// Create a new heap\nlet mut heap = Heap::default();\n\n// Temporary objects are cheaper than rooted objects, but don't survive heap cleans\nlet a = heap.insert_temp(Object::Num(42.0));\nlet b = heap.insert_temp(Object::Num(1337.0));\n\n// Turn the numbers into a rooted list\nlet c = heap.insert(Object::List(vec![a, b]));\n\n// Change one of the numbers - this is safe, even if the object is self-referential!\n*heap.get_mut(a).unwrap() = Object::Num(256.0);\n\n// Create another number object\nlet d = heap.insert_temp(Object::Num(0.0));\n\n// Clean up unused heap objects\nheap.clean();\n\n// a, b and c are all kept alive because c is rooted and a and b are its children\nassert!(heap.contains(a));\nassert!(heap.contains(b));\nassert!(heap.contains(c));\n\n// Because `d` was temporary and unused, it did not survive the heap clean\nassert!(!heap.contains(d));\n```\n\n## Who this crate is for\n\n- People writing dynamically-typed languages in Rust that want a simple, reliable garbage collector\n- People that want to have complex graph data structures with mutation and cycles but who don't want memory leaks\n\n## Who this crate is not for\n\n- People that want garbage collection when writing ordinary Rust code\n\n## Performance\n\nThis crate makes no specific promises about performance. It is designed with a 'best attempt' approach;\nthis means that it should be fast enough for most purposes but is probably not competitive with garbage\ncollectors that have had years of development work ploughed into them.\n\n## TODO\n\nThere are a few things I want to do with `broom` if I get the time:\n\n- Smarter cleanup strategies than mark 'n sweep\n- Partial cleans to prevent garbage collection lag spikes\n\nIf you're interested in working on any of these things, feel free to open a pull request!\n\n## License\n\nBroom is licensed under either of:\n\n- Apache License 2.0, (http://www.apache.org/licenses/LICENSE-2.0)\n\n- MIT license (http://opensource.org/licenses/MIT)\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzesterer%2Fbroom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzesterer%2Fbroom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzesterer%2Fbroom/lists"}