Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
javascriptのGC入門
Search
Taketoshi Aono(青野健利 a.k.a brn)
June 07, 2017
Programming
2
140
javascriptのGC入門
javascriptのGCの特徴やどのように動作するかの解説
Taketoshi Aono(青野健利 a.k.a brn)
June 07, 2017
Tweet
Share
More Decks by Taketoshi Aono(青野健利 a.k.a brn)
See All by Taketoshi Aono(青野健利 a.k.a brn)
document.write再考
brn
6
2.9k
Parsing Javascript
brn
12
9k
JSON & Object Tips
brn
1
400
CA 1Day Youth Bootcamp for Frontend LT
brn
0
790
Modern TypeScript
brn
2
750
javascript - behind the scene
brn
3
680
tc39 proposals
brn
0
780
プロダクト開発とTypeScript
brn
8
2.8k
React-Springでリッチなアニメーション
brn
1
600
Other Decks in Programming
See All in Programming
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Jakarta EE meets AI
ivargrimstad
0
140
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
最新TCAキャッチアップ
0si43
0
140
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
220
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.5k
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
1.9k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
133
8.9k
4 Signs Your Business is Dying
shpigford
180
21k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Practical Orchestrator
shlominoach
186
10k
Typedesign – Prime Four
hannesfritz
40
2.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Rails Girls Zürich Keynote
gr2m
94
13k
Automating Front-end Workflow
addyosmani
1366
200k
Side Projects
sachag
452
42k
Code Review Best Practice
trishagee
64
17k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Transcript
javascript Garbage Collector Overview
せ: @brn (ꫬꅿ⨳ⵃ) 耵噟: ؿٗٝزؒٝسؒٝآص،٥iOSؒٝآص، ⠓爡: Cyberagent ،سذؙأةآؔRightSegment٥AI Messenger ـؚٗ:
http://abcdef.gets.b6n.ch/
What is Garbage Collector? Garbage Collectorהכծفؚٗٓي⚥חⶴ䔲גؔـآؙؑزך 灶唱遤ְծًٌٔ걄㚖然⥂׃湫ׅךկ
What is Garbage Collector? var x = { a: 1,
b: 2 } Object Field a Field b Other Objects Heap ًٌٔⶴ䔲ג
What is Heap? Stack ꟼ侧 = ⠓陽 Heap مٙ؎زن٦س 陽✲ꐮ
What is Heap? Stackכꟼ侧⽃⡘דⶴ䔲גծꟼ侧ָ穄✪ׅה荈⹛ד灶唱ׁג׃ת ֲկ Heapכفؚٗٓيָ㶷㖈׃גְכ䌢ח⦼⥂㶷׃גֶֽկ javascriptכ䌢חHeapח⦼ⶴ䔲ג♳ծStackכ湫䱸ׁזְךדծ 罋ִ䗳銲כזְկ
What is Heap? Stack Process Stack Heap Process Stack Heap
Process 饯⹛儗 㹋遤⚥ 㹋遤⚥(㣐ꆀⶴ䔲ג)
What is Heap? OUT OF MEMORY
Garbage Collector 㟓ִֺׅHeapכ铩ַָ䰾ꤐ׃זֽלְֽזְկ ׃גֻךָ Garbage Collector
Garbage Collector ًٌٔⶴ䔲ג var x = {} var y
= {} Heap Global x y
Garbage Collector Garbage CollectorָHeapךⵋ麦〳腉זؔـآؙؑزחو٦ؙ➰ֽ Heap Global x y
Garbage Collector ًٌٔⶴ䔲ג var x = {} var y
= {} y = null Heap Global x y
Garbage Collector Garbage CollectorָHeapךⵋ麦〳腉זؔـآؙؑزחو٦ؙ➰ֽ Heap Global x y
Garbage Collector ًٌٔⶴ䔲ג var x = {}; var y
= {x: x}; x = null y.x = null Heap Global x y
Garbage Collector Garbage CollectorָHeapךⵋ麦〳腉זؔـآؙؑزחو٦ؙ➰ֽ Heap Global x y
Garbage Collector ًٌٔⶴ䔲ג var x = {}; var y
= {x: x}; x = null y = null Heap Global x y
Garbage Collector Garbage CollectorָHeapךⵋ麦〳腉זؔـآؙؑزחو٦ؙ➰ֽ Heap Global x y
Garbage Collector Heap Global x y Garbage CollectorָHeapךو٦ָؙזְؔـآؙؑز灶唱ׅ
Garbage Collector Garbage CollectorָHeapךⵋ麦〳腉זؔـآؙؑزو٦ؙ و و٦ ٦ؙ ؙؿ ؿؑ
ؑ؎ ؎ؤ ؤ(Mark Phase) Garbage CollectorָHeapךⵋ麦♶〳腉זؔـآؙؑز灶唱 أ أؐ ؐ؍ ؍٦ ٦ف فؿ ؿؑ ؑ؎ ؎ؤ ؤ(Sweep Phase)
Garbage Collector ָֿ و و٦ ٦ؙ ؙ، ،ٝ ٝس
سأ أؐ ؐ؍ ؍٦ ٦ف ف(Mark And Sweep) הְֲ،ٕ؞ٔؤيדׅկ
Garbage Collector ׃ծֿךMarkPhaseהSweepPhaseכ ؔـآؙؑزךخٔ٦וךדծفؚٗٓيך؟؎ؤח״גכծ ꬊ䌢ח頾蚚ַַָתׅկ ךծ植㖈ךـٓؐؠדכֿך⹛⡲㼰׃בא遤ֲծ ؎ ؎ٝ ؙٝ
ؙٔ ًٔ ًٝ ٝة ةٕ ٕGC(Incremental GC) הㄎל䩛岀ָ欽ְגְתׅկ זחMark&Sweepדفؚٗٓيָ⨡姺׃ג׃תֲֿה Stop the world הㄎןתׅկ
Incremental Garbage Collection Garbage CollectorָHeapךⵋ麦〳腉זؔـآؙؑزחو٦ؙ➰ֽ Heap Global x y 中断
Incremental Garbage Collection Garbage CollectorָHeapךو٦ָؙזְؔـآؙؑز灶唱ׅ Heap Global x y 中断
Incremental Garbage Collection Incremental GCכMark Phaseך鷿⚥ד撑ָ㢌⻉ׅ〳腉䚍ָ֮ծ ٓ؎زغٔ،(WriteBarrier) ה״לծ撑ָ剅ֹ㢌ֿה嗚濼ׅ➬穈ָ䗳銲חזתׅկ
Incremental Garbage Collection var x = {} var y =
{} y.x = x; Object(x) Heap Object(y) WRITED
Incremental Garbage Collection Garbage CollectorכWriteBarrierח״גو٦ׁؙؔـآؙؑزכ灶唱דֹזְ Heap Global x y 中断
WRITED 削除しない
Incremental Garbage Collection Incremental GCכفؚٗٓيך⨡姺儗䫇ִך،ٕ؞ٔؤيד֮ծ GC荈⡤ך儗כⰋ⡤涸ח⠼ןתׅկ ָծ⡤䠬ך鸞䏝כֶֻ傍ֻ䠬ׄתׅկ
Summary ֿך项俱כꬊ䌢ח邌涸ז铡僇דׅկ 劤勻GCכꬊ䌢ח醱꧟דծ➂겲ך〝兰ך穠兪הדְֲ״ֲזךזךדծ 莆ָ֮倯כה帾ֻ锃ץגגְֻׁկ ֮הծhttps://github.com/authorNari/minigcח449遤ךminiGCהְֲꬊ䌢؝ٝ ػؙزז㹋鄲ָ֮ךדծ鋅גגְֻׁկ ֿך ؖك٦آ؝ؙٖءّٝך،ٕ؞ٔؤيה㹋鄲הְֲ劤ֶָׅׅדׅկ https://www.amazon.co.jp/%E3%82%AC%E3%83%99%E3%83%BC%E3%82%B8%E3%82%B3%E3%83%AC %E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E3%82%A2%E3%83%AB
%E3%82%B4%E3%83%AA%E3%82%BA%E3%83%A0%E3%81%A8%E5%AE%9F%E8%A3%85-%E4%B8%AD%E6%9D %91-%E6%88%90%E6%B4%8B/dp/4798025623
׀ ׀幠 幠耮 耮֮ ֮ ָ ָה הֲ ֲ׀ ׀ׂ
ְׂ ְת ת׃ ׃