Giter VIP home page Giter VIP logo

malloc's Introduction

malloc

Description

fast and efficient malloc() algorithm (and of course free(), calloc(), realloc())

parts not inside mm.c (main malloc alorithm) were provided by the lecturer!, also some CSAPP libraries were used

Features

This project was complicated, because I couldn't use dynamic memory allocation here, so the data structure must be hidden inside the memory heap. Also alignments must be calculated carefully or you get some nasty, hard to find bugs (drawing on paper and using invariant checker helped though). Also, trying to optimize it against given memory traces was fun!

  • uses implicit list of free blocks divided into segments (each for a power of 2)
  • each segment is a linked list (FIFO)
  • information is encoded in headers and footers of blocks (no mallocs used in writing this malloc!)
  • performs careful padding for blocks to multiple of ALIGNMENT constant
  • finds first free block (first-fit) on appropiate segment for a given allocation
  • uses a prologue and epilogue block for blocks heap which are preallocated (with some additional free space) at the start of the program
  • extending heap by a larger value expecting more allocations
  • might perform split on allocation and coalescence on freeing
  • optimized reallocation
  • some tricks optimized for memory usage patterns provided by the lecturer
  • profiled for different variations of the algorithm (best-fit instead of first-fit, LIFO vs FIFO etc.)
  • invariant checker for debugging purposes to run and check for bugs inbetween allocations and deallocations

How to run

make -> for building whole project
make clean -> to clean directory from executable and object files
make format -> to format all .c files
make test -> to run test provided by the lecturer (sometimes may fail)

malloc's People

Contributors

arturjan4 avatar

Watchers

 avatar

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.