Skip to content

an experimental, depth-search-first memory leak detector and garbage collector for the C programming language

License

Notifications You must be signed in to change notification settings

exbotanical/gccgc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gccgc

automatic garbage collection & memory leak detection for the C programming language

What would it take to have automatic garbage collection for heap memory in C?

This is a small project intended to explore this notion; it is not intended to be consumed by production applications, nor is it intended to be an ideal solution.

Memory Leak Detection

First, we initialize a registrar in which all structures and aggregations thereof are recorded; this registrar includes metadata about each structure, such as its members, their respective sizes, and their members if applicable. The user must register dynamic objects using the gccgc API.

The registrar is comprised of nodes in a linked list, which are then arranged by gccgc into a directed cyclic graph. Each node contains flags utilized by a depth first search algorithm to inform the traverser whether the current node has been traversed, and whether the node constitutes as a root object. Traversal is implemented using the visitor pattern.

We begin traversal at the top-most, or root object of a structure. This object is often a global object for which memory leaks cannot be detected given the detection algorithm begins at the root object.

After traversing all objects, we recurse and visit their child objects. When running a memory leak report, any object that has been entered into the registrar but not marked as visited is an unreachable object such as a dangling pointer and is therefore a memory leak.

About

an experimental, depth-search-first memory leak detector and garbage collector for the C programming language

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published