Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thehxdev/cgc

A simple and tiny garbage collector in C for C
https://github.com/thehxdev/cgc

Last synced: 13 days ago
JSON representation

A simple and tiny garbage collector in C for C

Awesome Lists containing this project

README

        

# CGC

A simple and tiny garbage collector in C for C :)

I wrote it in probably 1 or 1.5 hours so it's not a big deal and not ment to be used
in other projects. It's only a hubby side project to practice how to implement a simple
GC in C programming language with my own understanding of memory and data structures without
reading any paper or documentation about automatic memory management or garbage collectors.

## How it works

It's only a wrapper for `malloc` and `calloc` functions to store allocated
memory chunkes in a doubly-linked-list to keep track of them.

then at the end of `main` function user must call `gc_freeAll` function to
free all of the allocated memory on the Heap.

## Problems

- It only triggers GC at the end of `main` function
- Bad code design with so much duplicated code (maybe solvable with macros)