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
goleak で goroutine leak を検出する
Search
kumatch
January 25, 2020
Programming
0
510
goleak で goroutine leak を検出する
kumatch
January 25, 2020
Tweet
Share
More Decks by kumatch
See All by kumatch
umedago-20190726.pdf
kumatch
0
57
Other Decks in Programming
See All in Programming
「Cursor/Devin全社導入の理想と現実」のその後
saitoryc
0
710
Kotlin エンジニアへ送る:Swift 案件に参加させられる日に備えて~似てるけど色々違う Swift の仕様 / from Kotlin to Swift
lovee
1
260
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
3
380
High-Level Programming Languages in AI Era -Human Thought and Mind-
hayat01sh1da
PRO
0
710
20250704_教育事業におけるアジャイルなデータ基盤構築
hanon52_
5
500
Porting a visionOS App to Android XR
akkeylab
0
220
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
220
Flutterで備える!Accessibility Nutrition Labels完全ガイド
yuukiw00w
0
140
ソフトウェア品質を数字で捉える技術。事業成長を支えるシステム品質の マネジメント
takuya542
1
6.1k
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
180
RailsGirls IZUMO スポンサーLT
16bitidol
0
150
NPOでのDevinの活用
codeforeveryone
0
730
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
How to Think Like a Performance Engineer
csswizardry
24
1.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Code Review Best Practice
trishagee
69
18k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Become a Pro
speakerdeck
PRO
28
5.4k
Transcript
goleak Ͱ gorou*ne leak Λݕग़͢Δ 2020-01-25 Umeda.go 2020 Winter Yosuke
Kumakura
About • kumatch / ۽༸հ • freee גࣜձࣾ ΤϯδχΞ •
࠷ۙͷؔ৺ےτϨ
gorou%ne leak • channel sync ύοέʔδͳͲΛͬͨʮͪঢ়ଶʯͷ gorou/ne • ϓϩηε͕ଓ͘ݶΓΔ
= memory leak • ͪࣗମ Go ϥϯλΠϜ͕ΑΖ͘͠Δ • CPU ফඅؾʹͳΒͳ͍
gorou%ne leak ൃੜͷྫ 1 func Do(ctx context.Context, send chan int)
chan int { 2 recv := make(chan int) 3 go func() { 4 for { 5 select { 6 case num := <-recv: 7 send <- num 8 case <-ctx.Done(): // if do not receive 9 return // if do not return 10 } 11 } 12 }() 13 return recv 14 }
uber-go/goleak • h#ps:/ /github.com/uber-go/goleak • gorou7ne leak Λͬ͘͞ͱݕग़Ͱ͖Δศརౕ • ࠷ۙ
(2020-01-08) v1.0.0 ʹͳͬͨ
uber-go/goleak usage import ( "testing" "go.uber.org/goleak" ) func TestMain(m *testing.M)
{ goleak.VerifyTestMain(m) }
uber-go/goleak demo h"ps:/ /github.com/kumatch-sandbox/goleak
uber-go/goleak ͷΈ • ςετ࣮ߦޙʹ run&me.Stack ͰελοΫτϨʔεΛऔΔ • ͦͷதͷ͏ͪ goleak ͕
gorou&ne Λআ֎ • ࣗΛ࣮ߦ͍ͯ͠Δ gorou&ne ͱ͔ • ʮͬͨ gorou&neʯɺऴΘͬͯͳ͍ͭͱͯ͠ѻ͍ग़ྗ
ߟྀ • ͋͘·Ͱ࣮ߦͨ݁͠Ռʹجͮ͘ݕग़ • ߏจղੳͯ͠Βͤͯ͘ΕΔΘ͚Ͱͳ͍ • ίʔυΧόϨοδ͕͍ɾ࣮ར༻ίʔυͱςετίʔυ͕૬ҧ ͍ͯ͠Δ߹࿙ΕΔՄೳੑ͕͋Δ • ςετͰޙॲཧ͔ͬ͠Γॻ͘͜ͱ
·ͱΊ • uber-go/goleak Λςετίʔυʹ͑ gorou.ne leak Λݟͭ ͚ΒΕΔ • طଘίʔυΛม͑Δ͜ͱͳ͘
TestMain() ʹҰߦॻ͚ͩ͘Ͱ ༗ޮ • ࣮ߦ݁Ռʹର͢Δݕग़ͷͨΊదͳར༻ମܥͰςετίʔυΛ ॻ͘͜ͱ