Download presentation
Presentation is loading. Please wait.
Published byTalia Creasey Modified over 9 years ago
1
Automatic Memory Management Noam Rinetzky Schreiber 123A http://www.cs.tau.ac.il/~maon/ http://www.cs.tau.ac.il/~maon/teaching/2014- 2015/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
http://gchandbook.org/
17
Schedule ChapterTopicDateLesson Chap.1Overview28-10-14 1 Chap. 2,3Mark-and-Sweep and Mark-compact GC04-11-142 Chap. 4,5Copying GC and reference counting11-11-143 Chap. 6,7Comparing GCs and allocation18-11-144 Chap. 8,9,10Partitioning and generational GC25-11-145 Chap. 11,12Runtime interface and language specific concerns02-12-146 Chap. 13Concurrency preliminaries09-12-147 Chap. 14Parallel GC16-12-148 Chap. 15Concurrent GC23-12-149 Chap. 16Concurrent mark-sweep GC30-12-1410 Chap. 17Concurrent copying and compaction GC06-01-1511 Chap. 18Concurrent reference-counting13-01-1512 Chap. 19Real-time GC20-01-1513
18
Admin
19
Requirements You are required to be present in every lesson – unless coordinated ahead with the lecturer Meet me before lecture – Sunday 1600-1700, 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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.