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
58
Other Decks in Programming
See All in Programming
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
2
640
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
3
770
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
770
#QiitaBash MCPのセキュリティ
ryosukedtomita
1
1.3k
Agentic Coding: The Future of Software Development with Agents
mitsuhiko
0
100
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
260
技術同人誌をMCP Serverにしてみた
74th
1
650
「テストは愚直&&網羅的に書くほどよい」という誤解 / Test Smarter, Not Harder
munetoshi
0
170
チームのテスト力を総合的に鍛えて品質、スピード、レジリエンスを共立させる/Testing approach that improves quality, speed, and resilience
goyoki
5
880
The Modern View Layer Rails Deserves: A Vision For 2025 And Beyond @ RailsConf 2025, Philadelphia, PA
marcoroth
1
150
おやつのお供はお決まりですか?@WWDC25 Recap -Japan-\(region).swift
shingangan
0
140
「Cursor/Devin全社導入の理想と現実」のその後
saitoryc
0
820
Featured
See All Featured
A better future with KSS
kneath
238
17k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.4k
Navigating Team Friction
lara
187
15k
Become a Pro
speakerdeck
PRO
29
5.4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Done Done
chrislema
184
16k
Code Review Best Practice
trishagee
69
18k
A designer walks into a library…
pauljervisheath
207
24k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
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() ʹҰߦॻ͚ͩ͘Ͱ ༗ޮ • ࣮ߦ݁Ռʹର͢Δݕग़ͷͨΊదͳར༻ମܥͰςετίʔυΛ ॻ͘͜ͱ