Controlling Garbage Collection and Heap Growth to Reduce the Execution Time of Java Applications - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Controlling Garbage Collection and Heap Growth to Reduce the Execution Time of Java Applications

Description:

Object-oriented programming language developed by Sun Microsystems in early 1990s ... Synchronously. Threading. Reclaiming Memory. JVM uses two broad techniques ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 21
Provided by: itc125
Category:

less

Transcript and Presenter's Notes

Title: Controlling Garbage Collection and Heap Growth to Reduce the Execution Time of Java Applications


1
Controlling Garbage Collection and Heap Growth to
Reduce the Execution Time of Java Applications
  • Azhar Khan (ICS)
  • ICS-599 Seminar

2
Outline
  • Java
  • Garbage Collection (GC)
  • GC Advantages and Drawbacks
  • Java GC
  • GC Algorithms
  • Bohem-Demers-Weiser (BDW) Collector
  • Threshold-Based Algorithm
  • Conclusion and Future Work

3
Java
  • Object-oriented programming language developed by
    Sun Microsystems in early 1990s
  • Platform independence
  • Java Virtual Machine (JVM)

4
Garbage Collection (GC)
  • Objects within a program's memory space that is
    unreachable from the program
  • Invented by John McCarthy around 1959

5
Garbage Collection (GC)
  • Removing unreferenced objects and Reclaiming
    Memory
  • GC too Frequently and Infrequently
  • Unnecessary overheads
  • Heap Size and Paging

6
Garbage Collection (GC)
  • Manual garbage-collection
  • Manual tracking and freeing
  • Automatic garbage-collection
  • Run-time system perform tracking and freeing

7
Garbage Collection (GC)
  • Manual garbage-collection
  • Pascal
  • C
  • C
  • Automatic garbage-collection
  • Java
  • Lisp
  • Smalltalk

8
Garbage Collection (GC)
  • Basic principle of Garbage Collector
  • Determine what data objects in a program will not
    be accessed in the future
  • Reclaim the resources used by those objects

9
GC Advantages and Drawbacks
  • Automatic GC saves Programmers time
  • Ensures Program Integrity
  • Extra overhead on JVM in case of JAVA
  • Programmers have less control of CPU Scheduling

10
Java GC
  • Synchronously
  • Threading
  • Reclaiming Memory
  • JVM uses two broad techniques
  • Run garbage collector to reclaim unused or
    unneeded heap memory.
  • Increase the heap size to accommodate application
    memory requirements

11
Fundamental Decisions
  • When allocating memory, what algorithm should be
    used?
  • If garbage collection is performed, which
    algorithm should be used?
  • When should garbage collection be performed
  • When should the heap be expanded, and by how much
    should it expand?
  • If the heap is being compacted, when should it be
    compacted?

12
GC Algorithms
  • Reference Counter
  • Keeps track the live objects
  • Mark-Sweep Collector
  • Mark Phase
  • Sweep Phase

13
GC Algorithms
  • Compacting Collector
  • Fragmentation
  • Sliding
  • Copying Collector
  • Two Regions
  • Stop and Copy

14
Bohem-Demers-Weiser (BDW) Collector
  • Mark-Sweep Collector
  • Object Types
  • Atomic Objects
  • Composite Objects
  • Free Space Divisor (FSD) Static Variable
  • Heap Size

15
Threshold-Based Algorithm
  • Checks if sufficient memory available.
  • Heap Grow Aggressively
  • Checks if available memory becomes low.
  • Avoid paging
  • GC more Aggressively and Heap less Aggressively
  • Tracking the amount of free memory.

16
BDW Collector Threshold-Based Algorithm
  • Decision based on
  • Heap Size
  • Available Memory
  • Threshold
  • Memory Allocator
  • Heap Size
  • GC
  • Amount of recent garbage collection

17
Threshold-Based Algorithm
  • Heap Grown
  • GC Collected
  • Neither

18
T4
T3
F
T2
J
C
H
E
T1
D
I
G
B
R1 lt S1 T2-T1
A
R2 gt S2 T2-T1
19
Conclusion Future work
  • Scheduling of GC and Heap Expansion
  • Decision based on Heap Size
  • Decision based on Memory Available.
  • Test Threshold-based Algorithm with different
    Garbage Collectors and consider multiple
    applications,

20
Questions
Write a Comment
User Comments (0)
About PowerShow.com