Giter VIP home page Giter VIP logo

dynamic-memory-allocator's Introduction

Dynamic memory allocator

Implementation of malloc(), free(), realloc(), calloc() in C.

There are three versions of the memory allocator. The mm-naive.c is the naive implementation of the memory allocator. It just uses the virtual memory as a large array of bytes to allocate memory and never frees memory. This approach achieves a high throughput (number of requests per time) at the expense of memory utilization. The second implementation mm-implicit.c uses an implicit list to store both allocated and free blocks. This version can reuse allocated blocks, thus achieving better memory utilization. However, since we keep a long list of allocated and free blocks, the running time of malloc() will be much longer. The third implementation mm-explicit.c balances throughput and memory utilization. It uses an explicit free list to store only free blocks since we don't care about allocated blocks. Memory utilization of mm-implicit.c and mm-explicit.c is roughly the same, but the explicit free list version has better throughput.

These implementations of malloc also impose a minimum block size of 4 words for each allocated block (header, footer, payload, and padding). With the free block in the explicit free list version, we can use the payload to store the predecessor and successor free blocks in the explicit free list.

Things to improve

Implement the memory allocator using a segregated free list. This is a more sophisticated version of the explicit free list one since it will keep track of many explicit free lists with different size classes. This design of the dynamic memory allocator achieves both high throughput and memory utilization.

dynamic-memory-allocator's People

Contributors

minhdang26403 avatar

Stargazers

Nguyễn Minh Tú 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.