# orangeduck/tgc

A Tiny Garbage Collector for C

Repository: https://github.com/orangeduck/tgc
Canonical: https://ross.abutalabs.com/products/tgc
Language: C
License: NOASSERTION
License Family: other
Last push: 2023-06-26T14:13:14+00:00

## Health v2 (maintenance only)
Score: 32/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 35, longevity 100
- inputs: {"age_days": 3788, "days_push": 1164, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases, no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1100, forks 69 (observed 2026-08-28T04:03:35.467598+00:00)

## What it is
tgc is a tiny (~500 line) conservative, thread-local mark-and-sweep garbage collector for C, provided as a single header. It automatically frees memory allocated via tgc_alloc and friends once it becomes unreachable, with support for destructors and manual collection.

## Use cases
- add garbage collection to a C program
- avoid memory leaks in C without manual free
- learn how a mark and sweep garbage collector works
- manage allocations in an interpreter or scripting engine written in C
- replace malloc with a GC-backed allocator in small C projects

## When to choose
- you want automatic memory management in C with minimal integration effort
- you need a small, readable GC you can embed and study
- your allocations stay on one thread and use tgc_alloc consistently

## When to avoid
- you need a multi-threaded or precise (non-conservative) collector
- pointers come from malloc'd memory, static data, or interior offsets
- you require guaranteed deterministic freeing or real-time latency
- you need a battle-tested GC for large production systems

## Facets
- artifact type: library
- maturity: maintenance
- function: developer-tools
- domain: developer-tools, programming-languages
- platform: c, cpp, cross-platform
- tags: garbage-collector, mark-and-sweep, conservative-gc, memory-safety, single-header, memory-management, garbage-collection

## Member repositories
- orangeduck/tgc (main) score 32

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:35.467598+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T08:22:59.633643+00:00, confidence not recorded.
  - readme: https://github.com/orangeduck/tgc (fetched 2026-08-28T04:03:35.467598+00:00, sha 2211e9757fb6)
- Data as of 2026-08-30T08:39:29.467469+00:00.
