Giter VIP home page Giter VIP logo

memory-management's Introduction

C based Memory Management

  1. Information

  2. Data Structure and Algorithms

    • We modefied the FreeNode data structure to have 3 fields:
    • size: an uintptr_t integer that gives the size of the block excluding the node's own size(16 bytes)
    • next: the pointer to the next block on the freelist
    • addr: the address of the block
    • The getmem and freemem functions share the single data structure freelist.
    • freelist is a linked-list of free memory blocks that are available to satisfy memory allocation requests.
    • When a request for memory is made, the freelist will be scanned to check if there's available block whose size is โ‰ฅ the size requested.
    • If a block with suitable size is found, it will be removed from freelist and a pointer to it is returned.
    • If the block found is substantially larger than the memory requested, the block will be split up, yielding a block that will satisfy the request and leaving the remainder on the freelist.
    • If there isn't an available block found, extendSpace() will be called to acquire a good-sized block of storage from the underlying system, add it to the free list, split it up, yielding a block that will satisfy the request, and leaving the remainder on the freelist.
    • If the size requested is way larger than predefined EXTRA_SIZE, then block acquired is of 'size', else of EXTRA_SIZE.
    • When a request to free memory is made, groupAdjacent() will be called to scan the freelist, in which process blocks that are adjacent to the given block in their physical memory address will be grouped into a bigger one. If no adjacent blocks are found, just insert the given block into the list at location 'p'.
  3. Additional Features and Optimization

    • In bench.c we seperated some part of the functions of main to a helper function that is called run_tests() for better modularization.
    • In mem_impl.h we introduced some helper functions as well that are used to create new nodes and thus initialize the list.
  4. Summary Of Benchmarking

    • We started our test with 100 trials and with an increment of factor of 10 up to 1 millon trials.
    • In our test, in average, we found out that it roughly took 0 milliseconds before 10k trials, 2-3 milliseconds around 10k trials,
    • around hundreds of milliseconds to run 100k trials and around 5 seconds to run 1 million trials.
    • In terms of memory usage, after 10k tirals it resulted in around 200 free blocks and an average of 8000 bytes per block.
    • Generally, requests with more large memory calls require more CPU time and storage space.
  5. Summary of Resources

    • Google (stackoverflow, geeksforgeeks), Lecture Slides, Panaptop Recordings, Ed discussion board and C documentation pages and tutorials.

memory-management's People

Contributors

ricoli424 avatar sgyli87 avatar

Stargazers

 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.