freelistmalloc's Introduction
Main file to look at is mm.c To see this malloc implementation work in a trace run make and then ./mdriver(driver and test code was provided by class staff) This file contains an implementation of the malloc method in C which when given a size, fetches a free and approrpriate block of memory to the requester for use. It also includes the related methods realloc, which takes an existing block and expands it to be of at least the given size, calloc which mallocs with instantiated 0s, and free, which frees a particular block of memory and is used in malloc itself. The goal of this malloc implementation is not only to give an apporpriate block of memory to the user, but to do so quickly and without demanding to much memory from the heap that isn't needed. In general free blocks are organized into segregated free lists, seperate lists which contain blocks who's size falls into a particular range. In this implementation, If a particular free list is empty the pointer to the head of that freelist points to the prologue and if a particular block is the last block in it's free list it's next pointer also points to the prologue. On a high level, when a user wants to malloc a particular block of memory, the program checks to see if a free block exsists in the free list that best corresponds to the size requested it picks roughly the first one it encounters looking ahead a set amount first to see if any following block is a better fit. If such a block does not exsist in that particular freelist the program looks in other buckets with free blocks large enough to accomdate the request, adding back any aligned excess memory back into the freelist whenever a block is found. If such a freeblock does not exist the program requests additional memory for the heap of a particular chunksize coalesces it with any neighboring free memory, returns the block to the user, and again adds back any excess aligned memory back into the approprirate free list. When a user decides to free a particulular block the program marks the block as unallocated, coalesces it with any adjacent free blocks and adds it to the approrpriate freelist.
freelistmalloc's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.