Memory allocation Flashcards

(9 cards)

1
Q

What Is Memory Allocation?

A

Memory allocation is how the operating system gives parts of memory (RAM) to processes so they can run programs.
It decides:
Where a program goes in memory
How much memory it gets
How to manage that memory while the program runs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Two Types of Memory Allocation

A

Static Allocation:
Memory is assigned at compile time.

Once set, it doesn’t change.

Example: global variables, fixed arrays

Dynamic Allocation:
Memory is assigned at runtime, as needed.

Can grow or shrink using functions like malloc() or free() in C.

Used for structures like linked lists, trees, etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Problem with Variable Size Allocation

A

Obvious approach, allocate just memory requested
* Placing things in memory (or on disk, etc.) with such
approach rapidly becomes big problem…
* If we free a large area of memory, disk, …– Tend to place something smaller in space, leaving a gap,
which prevents us from then storing something larger which leads to fragmentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fragmentation

A

Can become severe problem– Sum of un-allocated space can be large– Requires complex de-fragmentation
* Shuffling storage contents– Must be invisible to running processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Making best use of
Variable Size Regions

A

Dynamic storage allocation schemes…
– First fit and Next fit
* Always allocate first region of sufficient size found
– Best fit
* Always allocate smallest memory hole of sufficient size
– Worst fit
* Always allocate largest memory hole (of sufficient size)
* Aims to increase chance of later allocation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Variable vs. Fixed Sized Schemes

A

Variable/ Dynamic allocation schemes:
Allocate requested amount of memory– External fragmentation
* Space left outside/ between allocated memory

Fixed size schemes: Always allocate memory in fixed-sized blocks– Internal fragmentation
* Processes typically get more memory than requested,
rounded up to n * block size, which generally remains unused

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Fragmentation Issues

A

Internal Fragmentation: Wasted space inside an allocated block.

External Fragmentation: Wasted space between allocated blocks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Buddy Allocation Scheme

A

Idea is that a memory area can be split in two–Two buddies
- Likewise, two buddies can be combined– Reforming original pair into larger block
- Balances speed and memory use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Slab Allocation

A

Used in kernels.
Preallocates commonly used memory blocks.
Fast and efficient for objects like process control blocks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly