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
440
goleak で goroutine leak を検出する
kumatch
January 25, 2020
Tweet
Share
More Decks by kumatch
See All by kumatch
umedago-20190726.pdf
kumatch
0
50
Other Decks in Programming
See All in Programming
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
130
Java 22 Overview
kishida
1
180
Rubyでたのしむクリエイティブコーディング/Enjoy Creative coding with Ruby
chobishiba
1
180
코틀린으로 멀티플랫폼 만들기
pangmoo
0
150
使ってみよう Azure AI Document Intelligence
kosmosebi
2
300
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
490
雑に思考を整理する技術と効能
konifar
58
29k
Netty Chicago Java User Group 2024-04-17
sullis
0
170
Milestoner
bkuhlmann
1
410
Ruby GitHub Packages
bkuhlmann
0
630
Changed Rules: Architectures with Lightweight Stores
manfredsteyer
PRO
0
240
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
200
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
331
56k
Agile that works and the tools we love
rasmusluckow
325
20k
Teambox: Starting and Learning
jrom
128
8.4k
Build your cross-platform service in a week with App Engine
jlugia
225
17k
The Illustrated Children's Guide to Kubernetes
chrisshort
31
46k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Bash Introduction
62gerente
604
210k
Designing on Purpose - Digital PM Summit 2013
jponch
110
6.5k
A Tale of Four Properties
chriscoyier
151
22k
The Mythical Team-Month
searls
216
42k
Documentation Writing (for coders)
carmenintech
60
3.9k
Designing with Data
zakiwarfel
96
4.8k
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() ʹҰߦॻ͚ͩ͘Ͱ ༗ޮ • ࣮ߦ݁Ռʹର͢Δݕग़ͷͨΊదͳར༻ମܥͰςετίʔυΛ ॻ͘͜ͱ