Malloc Implementation

Malloc Implementation - Malloc Implementation There are...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Malloc Implementation There are several data structures that can be used for memory allocation: Single Free list Segregated Free Lists Cartesian Tree Boundary tags
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Malloc Single Free List In this implementation of malloc all the free memory is stored in a single free list. Each chunk in the free list has a header with the size of the chunk and a pointer to the next chunk.
Background image of page 2
Malloc Single Free List 640 head 200 400 0x110 0x4000 0x8000
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
During allocation a chunk of the right size if searched, split if necessary and the remainder is returned to the free list. When an object is freed, the free list is traversed to find the right place of insertion and the object is coalesced if possible. If the request cannot be satisfied with the existing free list, the allocator gets memory from the OS. The request for memory to the OS is larger (E.g. 8KB) than the size requested by malloc. This reduces the number of times memory is requested from the OS since this is slow. Chunks in the list are ordered by address
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/30/2012 for the course CS 354 taught by Professor Staff during the Fall '08 term at Purdue.

Page1 / 9

Malloc Implementation - Malloc Implementation There are...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online