1 / 35

Memory Management

Memory Management. Kathryn McKinley. About me. About You!. Course Logistics. Goals Presentations & Discussion Partner Written research problem identification and proposed solutions. Due date FIRM. Volunteers for next week?. Outline.

wnorris
Télécharger la présentation

Memory Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Memory Management Kathryn McKinley

  2. About me

  3. About You!

  4. Course Logistics • Goals • Presentations & Discussion • Partner • Written research problem identification and proposed solutions. Due date FIRM. • Volunteers for next week?

  5. Outline • Briefly introduce the challenges and key ideas in Memory Management • Explicit vs Automatic • Memory Organization • Contiguous allocation (bump pointer) • Free lists (analogous to pages in memory) • Reclamation • Tracing • Reference counting

  6. Memory Management • Program Objects/Data occupy memory • Problem: How does the runtime system efficiently create and recycle memory on behalf of the program? • What makes this problem important? • What makes this problem hard? • Why are researchers (e.g. me) still working on it?

  7. Dynamic memory allocation and reclamation • Heap contains dynamically allocated objects • Object allocation: malloc, new • Deallocation: • Manual/explicit: free, delete • automatic: garbage collection

  8. Explicit Memory ManagementChallenges • More code to maintain • Correctness • Free an object too soon - core dump • Free an object too late - waste space • Never free - at best waste, at worst fail • Efficiency can be very high • Gives programmers “control”

  9. Garbage collection:Automatic memory management • reduces programmer burden • eliminates sources of errors • integral to modern object-oriented languages, i.e., Java, C# • now part of mainstream computing • Challenge: • performance efficiency

  10. Key Issues • For both • Fast allocation • Fast reclamation • Low fragmentation (wasted space) • How to organize the memory space • Garbage Collection • Discriminating live objects and garbage

  11. Perfect Live Object Detection • live object has a future use • prove that object is not live, and deallocate it • do it as soon as possible after last use

  12. Estimating liveness in practice • approximate liveness by reachability from outside the heap • an unreachable object cannot ever be used – it is garbage • find and preserve reachable objects • Tracing or counting • recycle the space of garbage objects

  13. Identifying Garbage • Reference Counting (reachability) • Count the number of references to each object (RC) • If RC = 0, the object is garbage • Does not work for cycles

  14. Identifying Garbage • ‘Tracing’ (reachability) • Trace reachability from program ‘roots’ • Registers • Stacks • Statics • Objects not traced are unreachable

  15. Space Management • Two broad approaches: • Copying • Bump allocation & en masse reclamation • Fast allocation & reclaim • Space overhead, copy cost • Non-copying • Free-list allocation & reclamation • Space efficiency • Internal fragmentation

  16. Mapping Objects to Computer Resources Data Structure Declarations

  17. Contiguous Allocation New (Plate1)

  18. Contiguous Allocation New (Plate1) New (Plate2) New (Bowl1) New (Fork1) New (Fork2) New (Spoon1)

  19. Contiguous Allocation etc.

  20. Explicit Memory ManagementFree with Continuous Allocation Free (Bowl3)

  21. Free with Contiguous Allocation Free (Bowl3) Free (Spoon1)

  22. Garbage Collectionwith Contiguous Allocation Wait longer

  23. Garbage Collection with Contiguous Allocation L L Find live objects: L L L

  24. Garbage Collection with Contiguous Allocation Find live objects: L Copy live objects to new area L

  25. Garbage Collection with Contiguous Allocation Find live objects: L Copy live objects to new area Reclaim old space L

  26. Garbage Collection with Contiguous Allocation Find live objects: L Copy them to new area Reclaim old space Allocate into new space

  27. Allocation withSize-Class Free-Lists

  28. Explicit Memory Management:Free with Size-Classes Free-Lists Free (Bowl3) Free (Spoon1)

  29. Taxonomy of Design Choices • Incrementality • Composability • Concurrency • Parallelism • Distribution

  30. Incrementality • ‘Full heap’ tracing: • ‘Pause time’ goes up with heap size • Incremental tracing: • Bounded tracing time • Conservative assumption: • All objects in rest of heap are live • Remember pointers from rest of heap • Add ‘remembered set’ to roots for tracing • Generational Collectors • Collect young objects more frequently • Young objects die quickly

  31. Composability • Hybrids - example • Copy younger objects • Non-copying collection of older objects • Hierarchies • Copying intra-partition (increment) • Reference counting inter-partition

  32. Concurrency • ‘Mutator’ and GC operate concurrently

  33. Parallelism • Concurrency among multiple GC threads • Load balancing • Race conditions when tracing • Synchronization

  34. Distribution • Typically implies: • Incrementality • Concurrency • Parallelism • Composability • Detecting termination • When has a partition become isolated?

  35. GC Performance • Three key dimensions: • Throughput (bandwidth) • Responsiveness (latency) • Space • Measurement issues: • Selecting benchmarks • What makes a good GC Benchmark?

More Related