Beruflich Dokumente
Kultur Dokumente
Collection
Alex Harui
Flex SDK
Adobe Systems, Inc.
1
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection: Atomic Model
2
2005 Adobe Systems Incorporated. All Rights Reserved.
Flash Player Memory Management
3
2005 Adobe Systems Incorporated. All Rights Reserved.
Flash Player Memory Management
… …
4
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Does Not Run Constantly
512 bytes
512 bytes
512 bytes
5
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Does Not Run Constantly
512 bytes
512 bytes
512 bytes
6
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Does Not Run Constantly
512 bytes
512 bytes
7
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Does Not Run Constantly
512 bytes
512 bytes
8
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Is Only Triggered By
Allocations
512 bytes
Almost out!, Run GC!
512 bytes
9
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Is Only Triggered By
Allocations
10
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Does Not Run Completely
Before
11
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Does Not Run Completely
After
12
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Does Not Always Free OS
Memory
The collector will attempt to move blocks from one large chunk
to another to free an entire chunk to the OS
Won’t always be able to accomplish that in one pass
Before
512 bytes 512 bytes
13
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Does Not Always Free OS
Memory
The collector will attempt to move blocks from one large chunk
to another to free an entire chunk to the OS
Won’t always be able to accomplish that in one pass
After
512 bytes 512 bytes
14
2005 Adobe Systems Incorporated. All Rights Reserved.
Garbage Collection Is Not Predictable
15
2005 Adobe Systems Incorporated. All Rights Reserved.
Detecting Memory Leaks
16
2005 Adobe Systems Incorporated. All Rights Reserved.
Detecting Memory Leaks
17
2005 Adobe Systems Incorporated. All Rights Reserved.
Detecting Memory Leaks
18
2005 Adobe Systems Incorporated. All Rights Reserved.
Where To Find Memory Leaks
19
2005 Adobe Systems Incorporated. All Rights Reserved.
How Garbage Collection Works
20
2005 Adobe Systems Incorporated. All Rights Reserved.
How Garbage Collection Works
Stage
Starting from Stage you can follow arrows to all blue boxes
<mx:Application … >
<mx:Model id=“Model” />
<mx:VBox>
<mx:Button />
Application Model
.application
But not
GC’d Stage Popup’s Button
21
2005 Adobe Systems Incorporated. All Rights Reserved.
How Garbage Collection Works
ApplicationDomain\Class Definitions
Only static variables matter here.
Application Model
.application
22
2005 Adobe Systems Incorporated. All Rights Reserved.
How Garbage Collection Works
Stack/Local Variables
PopUpManager.createPopUp(Dialog, this);
class PopUpManager {
public static function createPopUp(popUpClass:Class,…) {
var popUp = new popUpClass();
Dialog instance
Stack
Unused return address
Unused class Dialog this
But not
GC’d ApplicationDomain Dialog
23
2005 Adobe Systems Incorporated. All Rights Reserved.
Removing EventListeners
.child
Application ChildComponent
.application
Unused SystemManager
.root
But not
GC’d Stage
24
2005 Adobe Systems Incorporated. All Rights Reserved.
Removing EventListeners
Application ChildComponent
.application
Unused SystemManager
.root
But not
GC’d Stage
25
2005 Adobe Systems Incorporated. All Rights Reserved.
Removing EventListeners
PopUp
Unused SystemManager
.root
But not
GC’d Stage
26
2005 Adobe Systems Incorporated. All Rights Reserved.
Removing EventListeners
PopUp
weak ref
Used mouseUpHandler mouseUpListeners
Unused
Unused SystemManager
.root
But not
GC’d Stage
27
2005 Adobe Systems Incorporated. All Rights Reserved.
Summary
28
2005 Adobe Systems Incorporated. All Rights Reserved.