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
JVM入門 -メモリ管理編-
Search
Kinoko
July 18, 2019
Programming
15
4.2k
JVM入門 -メモリ管理編-
関ジャバ'19 7月度 - connpass
https://kanjava.connpass.com/event/134133/
登壇資料
Kinoko
July 18, 2019
Tweet
Share
More Decks by Kinoko
See All by Kinoko
自作キーボードにチャレンジしてみた。 ver 2.0
sammy7th
0
1.9k
私が考える理想の開発チーム
sammy7th
0
570
ビジネスルールを軸とした ソフトウェア開発手法 「CCSR」
sammy7th
7
2.4k
お家に居れなくなって 3週間ゲストハウス暮らしをしていた話
sammy7th
2
460
家で仕事中にインターフォンに気づかず困っているのでIoTでなんとかしたい
sammy7th
1
130
ホットサンドメーカーで作るスイーツ
sammy7th
0
230
JVM入門 -Javaプログラムが動く仕組み-
sammy7th
35
13k
Udemyでプログラミング の動画講座を販売してみた
sammy7th
1
790
Git運用基礎
sammy7th
1
250
Other Decks in Programming
See All in Programming
cmp.Or に感動した
otakakot
2
140
初めてDefinitelyTypedにPRを出した話
syumai
0
400
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
Macとオーディオ再生 2024/11/02
yusukeito
0
370
役立つログに取り組もう
irof
28
9.6k
as(型アサーション)を書く前にできること
marokanatani
10
2.6k
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
110
Jakarta EE meets AI
ivargrimstad
0
600
Amazon Qを使ってIaCを触ろう!
maruto
0
400
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
890
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Teambox: Starting and Learning
jrom
133
8.8k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
BBQ
matthewcrist
85
9.3k
Producing Creativity
orderedlist
PRO
341
39k
Ruby is Unlike a Banana
tanoku
97
11k
Designing the Hi-DPI Web
ddemaree
280
34k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
It's Worth the Effort
3n
183
27k
Transcript
JVMೖ -ϝϞϦཧฤ- Abe Asami
ࣗݾհ "CF"TBNJl͖ͷࢠz େࡕͷϑϦʔϥϯεϓϩάϥϚ IUUQOPDPOPOFU !BBUI +BWB,PUMJO4DBMBͳͲͳͲ
࠷͍ۙͬͯΔ͜ͱ https://www.geekhub.jp/ ΤϯδχΞಛԽ߹ಉઆ໌ձΠϕϯτɻ࣍ճ 9/14() ։࠵༧ఆ ʮJava11ʹΑΔ WebΞϓϦέʔγϣϯ։ൃͰֶͿ Javaϓϩάϥϛϯάೖʯൢചத https://www.udemy.com/java11-springbootweb-java/
͜ͷςʔϚΛબΜͩཧ༝ • ਖ਼JVMͷ͜ͱงғؾͰ͔͠ཧղ͍ͯ͠ͳ ͍ͨΊɺษڧ͔͔ͨͬͨ͠Β • ӡ༻ϑΣʔζʹܞΘΔػձ͕গͳ͘ɺύ ϑΥʔϚϯεϝϞϦपΓͷτϥϒϧૺ۰ ܦݧ͕͋·Γͳ͍ɾɾɾ • ࠓϝϞϦཧͷ͚ͩͰ͢
ͦͦJVMͱ
Java VM (JavaԾϚγϯ) • JavaόΠτίʔυΛ࣮ߦ͢ΔͨΊͷԾڥ • OSґଘΛٵऩͯ͘͠Ε͍ͯΔ
JVMʹछྨ͕͋Δ • HotSpot VM, IBM JVM, JRockit, ͳͲͳͲ
ࠓճHotSpot VMͷ • Oracle͕ఏڙ͍ͯ͠ΔJVM
͋ͱࠓճJava8ͷͰ͢ • ͜ͷ͋ͱͷݕূͰͬͨͷ͕Java8
JVMͷΈ (ΊͬͪΌͬ͘͟Γ)
ϝϞϦߏ
None
None
None
None
None
None
None
None
None
None
None
࣮ࡍͷϓϩάϥϜͰ GCͷঢ়گΛղੳͯ͠ΈΔ
GCϩά • GCͷॲཧ࣌ؒલޙͷϝϞϦ༻ྔͳͲͷϩ ά
GCViewer • GCϩάͷϏϡʔΞʔ • https://github.com/chewiebug/GCViewer • 2019/07/18 ݱࡏɺJDK11ະରԠ
ͱΓ͋͑ͣɺ ͳΜ͔͠Βಈ͔ͯ͠ GCϩάΛग़ͯ͠ΈΔ
ࢀর͕Βͳ͍ΠϯελϯεΛ ͻͨ͢Βੜ
࣮ߦ java -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps Main GCϩάग़ྗͷͨΊͷΦϓγϣϯ (※ඪ४ग़ྗʹग़͚ͩ͢Ͱ͋Ε -verbose:gc
͚͚ͩͭΕOK)
ग़ྗ͞Εͨϩά
GCViewerͰ։͍ͯΈΔ
ΦϒδΣΫτ·ͣYoungྖҬʹ࡞ΒΕɺ ੜ͔Β͕࣌ؒܦͭͱOldྖҬʹҠಈ͢Δ
ࠓճOldྖҬͷҠಈ͕ൃੜ͠ͳ͍ͨΊ ώʔϓશମͷ༻ྔ ≒ YoungྖҬͷώʔϓ༻ྔ
GC࣌ʹͪΌΜͱϝϞϦ͕ղ์͞Ε͍ͯΔ
ϚΠφʔGCɾɾɾYoungྖҬͷΈ͕ର YoungྖҬ͕ ͍ͬͺ͍ʹͳͬͨ λΠϛϯάͰ ϚΠφʔGC͕ ࣮ߦ͞Ε͍ͯΔ
͏1ύλʔϯ ࢼͯ͠ΈΔ
ࢀর͕ΔΠϯελϯεΛ ͻͨ͢Βੜ
GCϩά
͜ΕGCViewerͰ։͍ͯΈΔ
None
Full GC (ϝδϟʔGC)ɾɾɾશώʔϓྖҬ͕ର
Full GC͕͔͔࣌ؒΔ 2019-07-18T07:28:35.759-0900: 53.145: [GC (Allocation Failure) [PSYoungGen: 1153507K->190965K(1768960K)] 1400776K->506242K(2118656K),
0.3026525 secs] [Times: user=2.55 sys=0.14, real=0.31 secs] 2019-07-18T07:28:36.064-0900: 53.450: [Full GC (Ergonomics) [PSYoungGen: 190965K->190932K(1768960K)] [ParOldGe 315276K->290297K(610816K)] 506242K->481229K(2379776K), [Metaspace: 2676K->2676K(1056768K)], 4.7517463 secs] [Times: user=29.92 sys=0.06, real=4.75 secs] ্ͷϚΠφʔGC ɾɾɾ 0.31 secs ԼͷFull GC ɾɾɾ 4.75 secs
GCதΞϓϦέʔγϣϯ εϨου͕ࢭ·Δ Stop the World (STW) ͱݺΕΔ
OutOfMemoryError(OOME) Λൃੜͤͯ͞ΈΔ
ώʔϓͷ࠷େαΠζΛมߋ ͯ͠ΈΔ % java -Xms600m -Xmx800m -Xloggc:gc.log -XX:+PrintGCDetails -XX: +PrintGCDateStamps
Main -Xms ɾɾɾώʔϓͷॳظαΠζ -Xmx ɾɾɾώʔϓͷ࠷େαΠζ
ແࣄ(?) OOMEൃੜ
GCϩά
͏ͪΐͬͱৄ͘͠ղੳΛ ͯ͠ΈΔ
ώʔϓμϯϓ • ಛఆͷ࣌ࠁʹώʔϓʹؚ·ΕΔͯ͢ͷΦϒ δΣΫτͷεφοϓγϣοτ
OOMEൃੜ࣌ʹώʔϓμϯϓΛ ग़ྗͤͯ͞ΈΔ java -Xms600m -Xmx800m -Xloggc:gc.log -XX:+PrintGCDetails -XX: +PrintGCDateStamps -XX:+HeapDumpOnOutOfMemoryError
Main -XX:+HeapDumpOnOutOfMemoryError ɾɾɾ OOMEൃੜ࣌ʹώʔϓμϯϓΛग़ྗ
The Eclipse Memory Analyzer • Eclipse Memory Analyzer Open Source
Project | The Eclipse Foundation https://www.eclipse.org/mat/ • ώʔϓμϯϓΛ͍͍ײ͡ʹදࣔͯ͘͠ΕΔGUI πʔϧ
ώʔϓμϯϓΛ։͍ͯΈͨ
None
None
·ͱΊ • ͜͏͍ͬͨJVMͷجຊൃੜ࣌ͷղੳํ ๏Λ͓ͬͯ͘ͱɺ͍͟ͱ͍͏ͱ͖ʹ߄ͯͳ ͯ͘ศར(ଟ)
ͪͳΈʹJava11ͷσʔλੳʹ Java Mission ControlΛ͏ͱ͍͍ͦ͏Ͱ͢ • Java Mission Control https://www.oracle.com/technetwork/jp/
java/javaseproducts/mission-control/ index.html • ༗ঈػೳ͕ͩͬͨɺJava11͔ΒOpenJDKʹ دଃ͞Εͯແঈఏڙͱͳͬͨ
ࢀߟʹͨ͠ϖʔδ • OutOfMemoryError ͷௐํ - Qiita https://qiita.com/opengl-8080/items/ 64152ee9965441f7667b • JavaͲͷΑ͏ʹಈ͘ͷ͔ʙਤղͰΘ͔ΔJVMͷΈɿ࿈ࡌʛgihyo.jp
… ٕज़ධࣾ http://gihyo.jp/dev/serial/01/jvm-arc • ʮϝϞϦʔΛҙࣝͯ͠ΈΑ͏ʯୈ2ճɹGCͷΈΛཧղ͢Δ | ܦ xTECH ʢΫϩεςοΫʣ https://tech.nikkeibp.co.jp/it/article/COLUMN/ 20060612/240657/?rt=nocnt • ·͡ΊʹJVMνϡʔχϯά: ୈ1ճ ·ͣݱঢ়֬ೝ https://x1.inkenkun.com/ archives/367
͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠