銆岀25璁层€?璋堣皥 JVM 鍐呭瓨鍖哄煙鍒掑垎锛屽摢浜涘尯鍩熷彲鑳藉彂鐢?OutOfMemoryError?|瀛︿範绗旇
Posted ETLshow
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了銆岀25璁层€?璋堣皥 JVM 鍐呭瓨鍖哄煙鍒掑垎锛屽摢浜涘尯鍩熷彲鑳藉彂鐢?OutOfMemoryError?|瀛︿範绗旇相关的知识,希望对你有一定的参考价值。
鏂?| ETLshow 锛堣浆杞借娉ㄦ槑鍑哄锛?/strong>
淇℃伅鐖嗙偢锛屾垜浠潵绛?/span>
馃挜馃挜馃挜
杩欐槸鎴戝涔犳瀬瀹㈡椂闂?nbsp;app 涓€奐ava鏍稿績鎶€鏈?6璁层€嬭绋嬬殑绗?nbsp;25 绡囧涔犵瑪璁帮紝鍧氭寔鍐欏畬 36 璁插涔犵瑪璁般€?/p>
1. JVM 鍐呭瓨鍖哄煙鐨勫垝鍒?/span>
Java 铏氭嫙鏈烘爤(Java Virtual Machine Stack)
姣忎釜绾跨▼鍦ㄥ垱寤烘椂閮戒細鍒涘缓涓€涓櫄鎷熸満鏍堬紝鍏跺唴閮ㄤ繚瀛樹竴涓釜鐨勬爤甯э紙Stack Frame锛?瀵瑰簲鐫€涓€娆℃鐨?Java 鏂规硶璋冪敤銆?br class="mq-18">鍦ㄤ竴涓椂闂寸偣锛屽搴旂殑鍙細鏈変竴涓椿鍔ㄧ殑鏍堝抚锛岄€氬父鍙綔褰撳墠甯э紝鏂规硶鎵€鍦ㄧ殑绫诲彨浣滃綋鍓嶇被銆?/span>
鏍堝抚涓瓨鍌ㄧ潃灞€閮ㄥ彉閲忚〃銆佹搷浣滄暟鏍堛€佸姩鎬侀摼鎺ャ€佹柟娉曟甯搁€€鍑烘垨鑰呭紓甯搁€€鍑虹殑瀹氫箟绛夈€?/span>鏈湴鏂规硶鏍?/span>(Native Method Stack)
涓?Java 铏氭嫙鏈烘爤绫讳技锛屾敮鎸佸鏈湴鏂规硶鐨勮皟鐢紝涔熸槸姣忎釜绾跨▼閮戒細鍒涘缓涓€涓€?/span>鍫?/span>(Heap)
瀹冩槸 JVM 鍐呭瓨绠$悊鐨勬牳蹇冨尯鍩燂紝GC 鍫嗭紝鐢ㄦ潵鏀剧疆 Java 瀵硅薄瀹炰緥銆?br class="mq-30">鍫嗭紝琚墍鏈夌嚎绋嬪叡浜€?/span>鏂规硶鍖?/span>(Method Area)
鐢ㄤ簬瀛樺偍鎵€璋撶殑鍏冿紙Meta锛夋暟鎹紝渚嬪绫荤粨鏋勪俊鎭紝浠ュ強瀵瑰簲鐨勮繍琛屾椂甯搁噺姹犮€佸瓧娈点€佹柟娉曚唬鐮佺瓑銆?br class="mq-36">鏂规硶鍖猴紝琚墍鏈夌嚎绋嬪叡浜€?/span>杩愯鏃跺父閲忔睜(Run-Time Constant Pool)
鏄柟娉曞尯鐨勪竴閮ㄥ垎銆傚瓨鏀惧悇绉嶅父閲忎俊鎭紝涓嶇鏄紪璇戝櫒鐢熸垚鐨勫悇绉嶅瓧闈㈤噺锛岃繕鏄渶瑕佸湪杩愯鏃跺喅瀹氱殑绗﹀彿寮曠敤銆?/span>
2. Java 杩涚▼鍐呭瓨鍗犵敤
绗?nbsp;1 鐐癸紝鏄?nbsp;JVM 瑙勮寖涓畾涔夌殑 JVM 杩愯鏃跺唴瀛樺崰鐢紝瑙勮寖渚ч噸鐨勬槸閫氱敤鐨勩€佹棤宸埆鐨勯儴鍒嗭紝瀵逛簬搴旂敤寮€鍙戣€呮潵璇达紝鍙鏄?nbsp;JVM 杩涚▼鍦ㄨ繍琛屾椂浼氬崰鐢紝閮戒細褰卞搷鍒版垜浠殑宸ョ▼瀹炶返銆傚洜姝ら渶瑕佽ˉ鍏呬袱鐐癸細
鐩存帴鍐呭瓨(Direct Memory)
Direct Buffer 鎵€鐩存帴鍒嗛厤鐨勫唴瀛樸€?/span>Code Cache
JVM 鏈韩鏄釜鏈湴绋嬪簭锛岃繕闇€瑕佸叾浠栫殑鍐呭瓨鍘诲畬鎴愬悇绉嶅熀鏈换鍔★紝姣斿锛孞IT Compiler 鍦ㄨ繍琛屾椂瀵圭儹鐐规柟娉曡繘琛岀紪璇戯紝灏变細灏嗙紪璇戝悗鐨勬柟娉曞瓨鍌ㄥ湪 Code Cache 閲岄潰锛汫C 绛夊姛鑳介渶瑕佽繍琛屽湪鏈湴绾跨▼涔嬩腑锛岀被浼奸儴鍒嗛兘瑕佸崰鐢ㄥ唴瀛樼┖闂淬€?/span>
3. 鍝簺鍖哄煙鍙兘鍙戠敓 OOM
OOM 灏辨槸 JVM 鍐呭瓨涓嶅鐢ㄤ簡锛屽嵆娌℃湁绌洪棽鍐呭瓨锛屽苟涓斿瀮鍦炬敹闆嗗櫒涔熸棤娉曟彁渚涙洿澶氬唴瀛樸€?/span>
闄や簡绋嬪簭璁℃暟鍣紝鍏朵粬鍖哄煙閮藉彲鑳戒細鍥犱负鍙兘鐨勭┖闂翠笉瓒冲彂鐢?OOM 銆?/span>
鍫?/span>
閿欒淇℃伅锛?java.lang.OutOfMemoryError:Java heap space"
鍘熷洜锛氬彲鑳藉瓨鍦ㄥ唴瀛樻硠闇查棶棰樸€佸彲鑳藉爢鐨勫ぇ灏忎笉鍚堢悊Java 铏氭嫙鏈烘爤鍜屾湰鍦版柟娉曟爤
閿欒淇℃伅锛?StackOverFlowError" "OutOfMemoryError"
鍘熷洜锛氬彲鑳界敱浜庝笉鏂殑杩涜閫掑綊璋冪敤
4. 鎬荤粨
鐢讳釜鍥惧氨寰堢洿瑙備簡锛屻€奐ava 鏍稿績鎶€鏈?nbsp;36 璁层€嬬殑鍥剧湡鐨勪笉閿欍€?/span>
5. 鍙傝€冩枃妗?/span>
銆奐ava 鏍稿績鎶€鏈?nbsp;36 璁层€?/span>
闀挎寜浜岀淮鐮佸叧娉?ETLshow
淇℃伅鐖嗙偢锛屾垜浠潵绛?/span>
鍠滄ETLshow
鐐瑰湪鐪嬪摝鈻?/span>
以上是关于銆岀25璁层€?璋堣皥 JVM 鍐呭瓨鍖哄煙鍒掑垎锛屽摢浜涘尯鍩熷彲鑳藉彂鐢?OutOfMemoryError?|瀛︿範绗旇的主要内容,如果未能解决你的问题,请参考以下文章