Presentation is loading. Please wait.

Presentation is loading. Please wait.

Automatic Memory Management Noam Rinetzky Schreiber 123A 2015/seminar/seminar1415a.html.

Similar presentations


Presentation on theme: "Automatic Memory Management Noam Rinetzky Schreiber 123A 2015/seminar/seminar1415a.html."— Presentation transcript:

1 Automatic Memory Management Noam Rinetzky Schreiber 123A /seminar/seminar1415a.html Semester A. Tuesday, 14:00-16:00. Schreiber 7

2 Scope Automatic algorithms for automatic memory management aka garbage collection – Sequential GC – Parallel GC – Concurrent GC – Real-time GC Focus on correctness

3 Programs with dynamic memory Programs manipulate resources – Files – Processes / threads – Connections – Memory malloc() / new() free() / delete() …. GC

4 Programming with dynamic memory typedef struct Data {int d; struct Data *n} Da; main(){ Da *p1 = (Da*) malloc(sizeof(Da)); p1  d = SECRET_KEY; Da *p2 = (Da*) malloc(sizeof(Da)); p2  d = 0; p1  n = p2; p2  n = null; free(p1); free(p2) }

5 Common mistakes Double free Memory leaks (no-free) Accessing dangling references Null-dereference Breaking invariants – p1  n = p2; p2  n = null; – p1  n = p2; p2  n = p1;

6 Undesired outcome… Crashes Incorrect behavior Security vulnerabilities Loss of life Loss of money Loss of reputation Loss of Job

7 Deallocation Allocation is “easy” “Deletion” is hard Nasty bugs Hard to get right – Defensive programming

8 Controlled Solutions Manual memory management – Runtime: Monitoring execution environment Catches errors Expensive – Compile-time: Verify memory safety Static analysis – Fully automatic / User-provided annotations Conservative – Problem is undecidable

9 Automatic Memory Management Exploit global knowledge – Hard to de-allocate based on local reasoning Simplifies code, Reduce coupling, Reduces errors, costs Sensitive & Chaotic (Locality, Program)

10 GC for the rescue Double free Memory leaks (no-free) Accessing dangling references Null-dereference Breaking invariants – p1  n = p2; p2  n = null; – p1  n = p2; p2  n = p1;

11 GC Runtime environment recycles memory that will not be used in the future of the execution – Cannot be used = unreachable Pros – Safe – Simple Cons – Runtime overhead – Imprecision (drag)

12 GC Challenges Unbounded number of resources Complicated data structures Efficiency Precision Correctness Multithreading makes things worse!

13 Comparing GC Algorithms Safety Throughput Completeness and promptness – Pause Space overhead Language-specific optimizations Scalability and portability

14 More issues Performance overhead Experimental methodology

15 Terminology Heap Mutator & Collector Mutator roots References, fields, addresses Liveness, correctness, reachability Allocator

16

17 Schedule ChapterTopicDateLesson Chap.1Overview Chap. 2,3Mark-and-Sweep and Mark-compact GC Chap. 4,5Copying GC and reference counting Chap. 6,7Comparing GCs and allocation Chap. 8,9,10Partitioning and generational GC Chap. 11,12Runtime interface and language specific concerns Chap. 13Concurrency preliminaries Chap. 14Parallel GC Chap. 15Concurrent GC Chap. 16Concurrent mark-sweep GC Chap. 17Concurrent copying and compaction GC Chap. 18Concurrent reference-counting Chap. 19Real-time GC

18 Admin

19 Requirements You are required to be present in every lesson – unless coordinated ahead with the lecturer Meet me before lecture – Sunday , Schreiber 123A

20 Requirements Give a 80 minutes talk about his or hers assigned topic. Answer students questions during the talk. Say something original Lead a discussion a summary discussion. Write a short (1 page) summary Participate in the discussions

21 Grades 70% Presentation 5% Original insight 10% Participation 15% Attendance

22 Paper Title Names of Authors Your Name + date

23 Outline of talk Introduction Suggested Solution Evaluation Related work Conclusions Your own conclusions

24 Introduction Problem area Technical challenged addressed Why is it important What is the main insight How is main insight utilized (high level)

25 Solution Technical description – Algorithm – Correctness – Complexity Choose key subset of details Use examples + diagrams

26 Evaluation Experiments Benchmarks Conclusions

27 Related work What other solutions are out there How do they compare – Pros – Cons

28 Conclusions What was done Why is it important Novel idea What we learned

29 Your own conclusion Surprise me


Download ppt "Automatic Memory Management Noam Rinetzky Schreiber 123A 2015/seminar/seminar1415a.html."

Similar presentations


Ads by Google