Storage Management Different-sized Items. Light blue indicates allocated items Heap Memory with Different-sized Items.

Slides:



Advertisements
Similar presentations
Memory management In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. Memory management is achieved.
Advertisements

Dynamic Memory Management
Chapter 6: Memory Management
Understanding Operating Systems Fifth Edition
1 Optimizing Malloc and Free Professor Jennifer Rexford COS 217 Reading: Section 8.7 in K&R book
Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Heap Management.
CPSC 388 – Compiler Design and Construction
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
1 1 Lecture 4 Structure – Array, Records and Alignment Memory- How to allocate memory to speed up operation Structure – Array, Records and Alignment Memory-
Memory Management Memory Areas and their use Memory Manager Tasks:
1 Optimizing Malloc and Free Professor Jennifer Rexford
Memory Management A memory manager should take care of allocating memory when needed by programs release memory that is no longer used to the heap. Memory.
CS61C L06 C Memory Management (1) Garcia, Fall 2006 © UCB Lecturer SOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine.
1 Inner Workings of Malloc and Free Professor Jennifer Rexford COS 217.
B-Trees. CSM B-Trees 2 Motivation for B-Trees So far we have assumed that we can store an entire data structure in main memory What if we have so.
Memory Allocation CS Introduction to Operating Systems.
Memory management. Instruction execution cycle Fetch instruction from main memory Decode instruction Fetch operands (if needed0 Execute instruction Store.
Real-Time Concepts for Embedded Systems Author: Qing Li with Caroline Yao ISBN: CMPBooks.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Dynamic Memory Allocation Questions answered in this lecture: When is a stack appropriate? When is a heap? What are best-fit, first-fit, worst-fit, and.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 32 Paging Read Ch. 9.4.
1. Memory Manager 2 Memory Management In an environment that supports dynamic memory allocation, the memory manager must keep a record of the usage of.
Skip Lists Mrutyunjay. Introduction ▪ Linked Lists Benefits & Drawbacks: – Benefits: – Easy Insert and Deletes, implementations. – Drawbacks: – Hard to.
B-Trees. CSM B-Trees 2 Motivation for B-Trees So far we have assumed that we can store an entire data structure in main memory What if we have so.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Chapter 4 Memory Management.
Subject: Operating System.
B-Trees. CSM B-Trees 2 Motivation for B-Trees So far we have assumed that we can store an entire data structure in main memory What if we have so.
CSC 360, Instructor: Kui Wu Memory Management II: Virtual Memory.
Dynamic Memory Allocation II
University of Washington Today More memory allocation!
Lecture 7 Page 1 CS 111 Summer 2013 Dynamic Domain Allocation A concept covered in a previous lecture We’ll just review it here Domains are regions of.
VIRTUAL MEMORY Virtual Address Space. In computing, virtual address space (abbreviated VAS) is a memory mapping mechanism available in modern operating.
CSE 351 Dynamic Memory Allocation 1. Dynamic Memory Dynamic memory is memory that is “requested” at run- time Solves two fundamental dilemmas: How can.
Dynamic Memory Management Jennifer Rexford 1. 2 Goals of this Lecture Dynamic memory management techniques Garbage collection by the run-time system (Java)
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
8/3/2007CMSC 341 BTrees1 CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
Eliminating External Fragmentation in a Non-Moving Garbage Collector for Java Author: Fridtjof Siebert, CASES 2000 Michael Sallas Object-Oriented Languages.
Linked Lists Source: presentation based on notes written by R.Kay, A. Hill and C.Noble ● Lists in general ● Lists indexed using pointer arrays ● Singly.
Section 10: Memory Allocation Topics
Memory Management Memory Areas and their use Memory Manager Tasks:
Jonathan Walpole Computer Science Portland State University
Memory management.
Partitioned Memory Allocation
Dynamic Domain Allocation
26 - File Systems.
Upper Bound for Defragmenting Buddy Heaps
Memory Management Memory Areas and their use Memory Manager Tasks:
Optimizing Malloc and Free
Disk Storage, Basic File Structures, and Buffer Management
CS Introduction to Operating Systems
What Happens if There is no Free Frame?
B- Trees D. Frey with apologies to Tom Anastasio
B- Trees D. Frey with apologies to Tom Anastasio
Optimizing Dynamic Memory Management
Memory Allocation II CSE 351 Autumn 2017
OS – Memory Deallocation
B- Trees D. Frey with apologies to Tom Anastasio
B-TREE ________________________________________________________
Contents Memory types & memory hierarchy Virtual memory (VM)
Memory Allocation II CSE 351 Winter 2018
Memory Management (1).
Copyright © Curt Hill Page Management In memory and on disk Copyright © Curt Hill.
Memory Allocation II CSE 351 Winter 2018
Memory Management Memory Areas and their use Memory Manager Tasks:
CS703 - Advanced Operating Systems
B-Trees.
B-Trees.
COMP755 Advanced Operating Systems
Module IV Memory Organization.
Presentation transcript:

Storage Management Different-sized Items

Light blue indicates allocated items Heap Memory with Different-sized Items

Light blue indicates allocated items Free some items

Light blue indicates allocated items Free some items Although we have 50 free bytes, we can’t satisfy a request for more than 30 bytes

Light blue indicates allocated items Free another item We need to recognize when two adjacent items are free. How can we recognize that two adjacent items are free? Suppose all free nodes are on a free linked list. Since the free bytes aren’t being used, they easily can be made “free” nodes. We could follow the free list and see if any node’s address + size is the address of the recent free node. Free List Head

Light blue indicates allocated items Free another item Combine them. Free List Head

Light blue indicates allocated items Free another item Combine them. Free List Head

Of course, the item being freed could precede a free item already in the list What if there is a free item after a newly freed item?

Free List Head Of course, the item being freed could precede a free item already in the list We can check the next item to see if its indicator indicates free. We also need to update the free list. Do we really need to search the entire list? What could we change to avoid that search? What if there is a free item after a newly freed item?

Free List Head The newly freed item might be between two already free items. What if the newly freed item is surrounded by free items?

Free List Head The newly freed item might be between two already free items. So, we need to always check before and after it. What if the newly freed item is surrounded by free items?

Free List Head Suppose we need to allocate an item of 40 bytes, where should we place it? Algorithms: First Fit - scan the free item list looking for the first free item of N or more bytes. Allocate N bytes from the free item and the remainder might be free space. Best Fit - scan the free item list looking for the first free item with the minimum number of bytes >= N. How can we optimize this search? Which free item to use when allocating?

Light blue indicates allocated items What happens if we need to allocate a 48 byte item? Free List Head Can there be an issue with the left over free space?

Light blue indicates allocated items What happens if we need to allocate a 48 byte item? The free portion is too small for the standard free node format. What should we do? Free List Head ? Can there be an issue with the left over free space?