Giter Site home page Giter Site logo

garbage-collector's Introduction

Garbage Collector

A garbage collector library, made as a project for my DSA - II course, implemented in C language.

Name: Sameer Kavthekar
MIS: 111903153
Division 2

Features

This garbage collector implements the mark and sweep algorithm along with the LISP2 algorithm for compaction. This library allows you to:

  1. Dynamically allocate memory on the heap
  2. Free allocated memory
  3. Collect all garbage memory and free it automatically
  4. Compact memory after freeing it
  5. Compaction is enabled by default. To turn it off you can run the program by using -gC flag.

Working

The main functions of my program are:

  1. gc_malloc() This is the function that dynamically allocates memory. This function adds a header, containing metadata to every allocated object. This helps in tracking and collection of the object.
  2. gc_free() This function primarily deals with freeing garbage in the heap. This function frees the object as well as the header.
  3. gc_mark() A function that recursively marks all the objects that are reachable from roots (i.e. pointers on the stack, pointers in the registers, global variables).
  4. gc_sweep() A function that frees every valid object that is not marked.
  5. gc_compact() A function that compacts the memory i.e. it moves all the live objects to the start of the heap.

Usage

Make sure you have gcc installed You can check by typing the following in your terminal

$ gcc --version

Clone the repository

$ git clone  https://github.com/sameerkavthekar/garbage-collector.git

Copy gc.c, gc.h, hashmap.c and hashset.c from the src/ folder to your project directory and include gc.h in your main file

#include "gc.h"

Compile program by using

gcc yourfiles.c gc.c hashmap.c hashset.c -o yourfile

References

garbage-collector's People

Contributors

sameerkavthekar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

garbage-collector's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.