What about other storage reclamation schemes? Memory management - - PowerPoint PPT Presentation

what about other storage reclamation schemes memory
SMART_READER_LITE
LIVE PREVIEW

What about other storage reclamation schemes? Memory management - - PowerPoint PPT Presentation

What about other storage reclamation schemes? Memory management options Manual /explicit memory management Strengths? Challenges? Automated memory management (garbage collection) Strengths? Challenges? Any others? 2


slide-1
SLIDE 1

What about other storage reclamation schemes?

slide-2
SLIDE 2

Memory management options

 Manual /explicit memory management

 Strengths?  Challenges?

 Automated memory management (garbage collection)

 Strengths?  Challenges?

 Any others?

2

slide-3
SLIDE 3

Real-time garbage collection (RTGC)

 Real-time system

 A system that meets real-time requirements.

 Real-time requirements

 As expected, operations must be logically correct  Additionally, operations must be completed within

deadline

 RTGC

 Bounded-time allocation  Predictable deallocation  Must be incremental

3

slide-4
SLIDE 4

Real-time garbage collection (RTGC)

4

public void f(){ startLaser(); Obj o = new Obj(); stopLaser(); } public static void main(…){ f(); } Time

Good for Real-Time

slide-5
SLIDE 5

RTGC strengths and challenges

 Need extra storage

 Store state of application when collector runs

 Application can allocate memory during garbage

collection

 Space-time trade-off

5

slide-6
SLIDE 6

RTSJ scoped-memory

 RTSJ – Real-time specification for Java proposed by the

Real-time for Java expert group (RTJEG).

 Semi-manual with scopes

 Scopes: regions of memory  Scopes: limited life times  Threads allocate from current scope  Predictable allocation  Predictable deallocation  No dangling pointers

6

slide-7
SLIDE 7

RTSJ scoped-memory

7

ScopedMemory scope = new ScopedMemory(1024); scope.enter(new Runnable() { public void run(){ // do some stuff someObj o = new someObj(); // do some more stuff someObj s = new someObj(); } }); // scope is collected (no threads)

slide-8
SLIDE 8

RTSJ scoped-memory challenges

 Restrictive memory model  Difficult to use  Can leak memory

8

slide-9
SLIDE 9

Memory management options

 Manual/explicit memory management  Automated memory management (GC)  Real-time garbage collection  RTSJ scoped-memory

9

slide-10
SLIDE 10

Garbage collection design choices

 Stop-the-world  Incrementality  Hybrid  Concurrency  Parallelism

10

slide-11
SLIDE 11

Stop-the-world collectors

 Typically used on uniprocessor systems  Suspend application  Run collector from start to finish  Resume application

11

slide-12
SLIDE 12

Stop-the-world collectors

 Execution costs?

 Pause time  Discovery of live objects (how long does it take?)  Instruction overhead (per instruction)  Delay between object death and collection  Number of collectible objects collected  Overall execution time  Worst-case vs average case performance  frequency

12

slide-13
SLIDE 13

Incremental collection

 Interleave GC with application  Note: for full heap tracing

 Pause time increases with heap size

 Incremental tracing

 Bounded tracing time  Conservative assumption

 All other objects in heap are live

 Remember pointers from objects in heap

 Add such pointers to root set for tracing

13

slide-14
SLIDE 14

Hybrid collection

 Generational collectors

 Collect young objects frequently

 Young objects die quickly

 Example

 Copy collection for young objects  Non-copy collection for older objects

 Partitioning

 Copy intra-partition incrementally  Reference count inter-partition

14

slide-15
SLIDE 15

Concurrent collection

 Application is called a mutator  GC regards application as such because it is mutating

the heap

 Mutator and GC function at the same time except

when GC needs info from mutator

 Synchronization

15

slide-16
SLIDE 16

Parallel collection

 Concurrency among multiple GC threads

 Load balancing  Synchronization  Race condition when tracing

16