All Projects → GJDuck → GC

GJDuck / GC

Licence: other
A lightweight conservative garbage collector for C/C++

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to GC

on-the-fly-gc
Concurrent mark-sweep garbage collector for accurate garbage collection of language runtimes in C++ 1x.
Stars: ✭ 25 (-76.85%)
Mutual labels:  garbage-collector, memory-management
smalloc
SMalloc -- a *static* memory allocator.
Stars: ✭ 22 (-79.63%)
Mutual labels:  memory-management, memory-allocation
cactusref
🌵 Cycle-Aware Reference Counting in Rust
Stars: ✭ 129 (+19.44%)
Mutual labels:  garbage-collector, memory-management
buddy alloc
A single header buddy memory allocator for C
Stars: ✭ 46 (-57.41%)
Mutual labels:  memory-management, memory-allocation
Sralloc
Memory allocators
Stars: ✭ 25 (-76.85%)
Mutual labels:  memory-management, memory-allocation
MemoryAllocator.KanameShiki
Fast multi-threaded memory allocator
Stars: ✭ 73 (-32.41%)
Mutual labels:  memory-management, memory-allocation
mmtk-core
Memory Management ToolKit
Stars: ✭ 205 (+89.81%)
Mutual labels:  garbage-collector, memory-management
Rmm
RAPIDS Memory Manager
Stars: ✭ 154 (+42.59%)
Mutual labels:  memory-management, memory-allocation
Scalene
Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python
Stars: ✭ 4,819 (+4362.04%)
Mutual labels:  memory-management, memory-allocation
Heap Layers
Heap Layers: An Extensible Memory Allocation Infrastructure
Stars: ✭ 260 (+140.74%)
Mutual labels:  memory-management, memory-allocation
Heapinspector For Ios
Find memory issues & leaks in your iOS app without instruments
Stars: ✭ 1,819 (+1584.26%)
Mutual labels:  memory-management, memory-allocation
java-memory-agent
Java Memory Agent for Container RAM Usage Optimization
Stars: ✭ 35 (-67.59%)
Mutual labels:  garbage-collector, memory-management
zerogc
Zero overhead tracing garbage collection for rust (WIP)
Stars: ✭ 39 (-63.89%)
Mutual labels:  garbage-collector
NALib
General purpose C sourcecode collection
Stars: ✭ 16 (-85.19%)
Mutual labels:  memory-management
elasticsearch-hints
Some useful links about Elasticsearch
Stars: ✭ 21 (-80.56%)
Mutual labels:  garbage-collector
openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,973 (+2652.78%)
Mutual labels:  garbage-collector
D3d12memoryallocator
Easy to integrate memory allocation library for Direct3D 12
Stars: ✭ 234 (+116.67%)
Mutual labels:  memory-management
total
Ruby Gem to get total memory size in the system
Stars: ✭ 15 (-86.11%)
Mutual labels:  memory-management
archery
Abstract over the atomicity of reference-counting pointers in rust
Stars: ✭ 107 (-0.93%)
Mutual labels:  memory-management
Mono
Mono open source ECMA CLI, C# and .NET implementation.
Stars: ✭ 9,606 (+8794.44%)
Mutual labels:  garbage-collector

GC

A lightweight conservative Garbage Collector (GC) for C/C++ on 64-bit CPUs.

The basic idea of this GC is as follows: during initialization the GC allocates (from the operating system) a very large 3072GB memory pool. This pool never shrinks nor grows, simplifying the overall collector design. Initially the pool is 100% virtual memory -- so there is no problem allocating such a large pool on 64bit systems. Physical memory is only committed to the pool on demand as it is allocated as used by the program. This simply uses the underlying demand-paging mechanism of the operating system.

The simplified memory model has some advantages, such as a significant simplification of the memory allocation and collection algorithms. This reduces the size and complexity of the collector, e.g. the main source file gc.c is less that 1,000SLOC. There are some additional benefits, such as optimized implementations some GC API functions, such as GC_size and GC_base.

Our implementation is currently only single-threaded. On the benchmarks we have tried, our collector is competitive with the more mature Boehm GC, and can be a lot faster for programs that make use of the optimized GC API functions.

Systems

Currently 64-bit Linux, MacOSX, and Windows are supported. The GC compiles with gcc (Linux/MacOSX) and mingw-64 (Windows).

Building

Our collector is written in gnu99, i.e., C99 with GNU extensions. To compile simply use gcc --std=gnu99 -c gc.c.

Caveats

Unlike the famous Boehm collector, our GC is missing a lot of features. There are some caveats to be aware of:

  • Only 64-bit CPUs are supported. This is a fundamental limitation of this kind of GC.
  • Automatic root discovery is not supported. Roots much be registered manually with GC_root().
  • No special support for atomic memory.
  • Not multi-threaded; only use for single-threaded programs.
  • Maximum allocation size is 255MB.
  • Allocation of /huge/ objects, i.e. > 1MB, is rounded up to the nearest MB boundary, which is not ideal. In the future we plan to fix this by recording the object size for huge allocations.
  • The Windows port was the most problematic. Windows artificially limits the usable virtual address space to a measly 8TB (presumably they thought 8TB ought to be enough for everybody?), and gets annoyed if you try to reserve too much of it. As a consequence, the memory pool is on Windows is limited to 1TB. This does not cause any problems for most applications.

About

This GC was designed and implemented by Gregory J. Duck. The official website is here:

http://www.comp.nus.edu.sg/~gregory/GC/

The main application for this GC is the SMCHR system:

http://www.comp.nus.edu.sg/~gregory/smchr/

The SMCHR system is a reasonably big project (>20,000 LOC). Since this GC design is so lightweight, it is reasonable to incorporate into the SMCHR source code directly, rather building it as a library and adding an external dependency. This is not generally feasible with the considerably larger Boehm collector.

Related Work

The fast GC_size and GC_base operations have some useful applications, such as for runtime bounds checking of heap allocated objects. The memory allocator design (minus the "GC" bit) became the basis of our work on "low fat pointers" resulting in two publications:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].