http://blog.cs" />
MyException - 我的异常网
当前位置:我的异常网» 编程 » JAVA鍐呭瓨浣跨敤-濡備綍璁$畻涓€涓狫ava瀵硅薄鍗

JAVA鍐呭瓨浣跨敤-濡備綍璁$畻涓€涓狫ava瀵硅薄鍗犵敤鐨勫瓧鑺傛暟

www.MyException.Cn  网友分享于:2013-02-18  浏览:5次
JAVA鍐呭瓨浣跨敤--濡備綍璁$畻涓€涓狫ava瀵硅薄鍗犵敤鐨勫瓧鑺傛暟

杞浇锛?a href="http://blog.csdn.net/kp034/article/details/7077757">http://blog.csdn.net/kp034/article/details/7077757

鍘熸枃鍦板潃:鐐瑰嚮鎵撳紑閾炬帴 ,缈昏瘧鏈夊嚭鍏ヤ箣澶勶紝璇蜂互鍘熸枃涓哄噯

鏈枃涓紝鎴戜滑璁ㄨ涓€涓棶棰橈細濡備綍璁$畻(鎴栬€呰锛屼及绠?涓€涓狫ava瀵硅薄鍗犵敤鐨勫唴瀛樻暟閲忥紵

閫氬父锛屾垜浠皥璁虹殑鍫嗗唴瀛樹娇鐢ㄧ殑鍓嶆彁鏄互鈥滀竴鑸儏鍐碘€濅负鑳屾櫙鐨勩€備笉鍖呮嫭涓嬮潰涓ょ鎯呭舰锛?/span>

鏌愪簺鎯呭喌涓嬶紝JVM鏍规湰灏辨病鏈夋妸Object鏀惧叆鍫嗕腑銆備緥濡傦細鍘熷垯涓婅锛屼竴涓皬鐨則hread-local瀵硅薄瀛樺湪浜庢爤涓紝鑰屼笉鏄湪鍫嗕腑銆?/span>

琚玂bject鍗犵敤鍐呭瓨鐨勫ぇ灏忎緷璧栦簬Object鐨勫綋鍓嶇姸鎬併€備緥濡傦細Object鐨勫悓姝ラ攣鏄惁鐢熸晥锛屾垨鑰咃紝Object鏄惁姝e湪琚洖鏀躲€?/span>

鎴戜滑鍏堟潵鐪嬬湅鍦ㄥ爢涓崟涓殑Object闀夸粈涔堟牱瀛?/span>

鍦ㄥ爢涓紝姣忎釜瀵硅薄鐢卞洓涓煙鏋勬垚锛圓銆丅銆丆 鍜?D锛夛紝涓嬮潰鎴戜滑閫愪釜瑙i噴涓€涓嬶細

A:瀵硅薄澶达紝鍗犵敤寰堝皯鐨勫瓧鑺傦紝琛ㄨ堪Object褰撳墠鐘舵€佺殑淇℃伅

B:鍩烘湰绫诲瀷鍩熷崰鐢ㄧ殑绌洪棿(鍘熺敓鍩熸寚 int銆乥oolean銆乻hort绛?

C:寮曠敤绫诲瀷鍩熷崰鐢ㄧ殑绌洪棿(寮曠敤绫诲瀷鍩熸寚 鍏朵粬瀵硅薄鐨勫紩鐢紝姣忎釜寮曠敤鍗犵敤4涓瓧鑺?

D:濉厖鐗╁崰鐢ㄧ殑绌洪棿(鍚庨潰璇存槑浠€涔堟槸濉厖鐗?

涓嬮潰鎴戜滑瀵笰銆丅銆丆 鍜?D 閫愪竴瑙i噴

A锛氬璞″ご

聽 鍐呭瓨涓紝姣忎釜瀵硅薄鍗犵敤鐨勬€荤┖闂翠笉浠呭寘鍚璞″唴澹版槑鐨勫彉閲忔墍闇€瑕佺殑绌洪棿锛岃繕鍖呮嫭涓€浜涢澶栦俊鎭紝姣斿锛氬璞″ご 鍜?濉厖鐗┿€傗€滃璞″ご鈥濈殑浣滅敤鏄敤鏉ヨ褰曚竴涓璞$殑瀹炰緥鍚嶅瓧銆両D 鍜?瀹炰緥鐘舵€侊紙渚嬪锛屽綋鍓嶅疄渚嬫槸鍚︹€滃彲鍒拌揪鈥濓紝鎴栬€呭綋鍓嶉攣鐨勭姸鎬佺瓑绛夛級銆?/span>

鍦ㄥ綋鍓嶇殑JVM鐗堟湰涓紙Hotspot锛夛紝鈥滃璞″ご鈥濆崰鐢ㄧ殑瀛楄妭鏁板涓嬶細

涓€涓櫘閫氬璞★紝鍗犵敤8 bytes

鏁扮粍锛屽崰鐢?12 bytes锛屽寘鍚櫘閫氬璞$殑 8 bytes + 4 bytes锛堟暟缁勯暱搴︼級

B锛氬熀鏈被鍨?/span>

boolean銆乥yte 鍗犵敤 1 byte锛宑har銆乻hort 鍗犵敤 2 bytes锛宨nt銆乫loat 鍗犵敤 4 bytes锛宭ong銆乨ouble 鍗犵敤 8 bytes

C锛氬紩鐢ㄧ被鍨?/span>

聽 姣忎釜寮曠敤绫诲瀷鍗犵敤 4 bytes

D锛氬~鍏呯墿

鍦℉otspot涓紝姣忎釜瀵硅薄鍗犵敤鐨勬€荤┖闂存槸浠?鐨勫€嶆暟璁$畻鐨勶紝瀵硅薄鍗犵敤鎬荤┖闂?瀵硅薄澶?澹版槑鍙橀噺)涓嶈冻8鐨勫€嶆暟鏃跺€欙紝鑷姩琛ラ綈銆傝€岋紝杩欎簺琚~鍏呯殑绌洪棿锛屾垜浠彲浠ョО瀹冧负鈥滃~鍏呯墿鈥濄€傛垜浠湅涓嬪叿浣撳疄渚嬶細

涓€涓┖瀵硅薄锛堟病鏈夊0鏄庝换浣曞彉閲忥級鍗犵敤 8 bytes -- > 瀵硅薄澶?鍗犵敤 8 bytes

鍙0鏄庝簡涓€涓猙oolean绫诲瀷鍙橀噺鐨勭被锛屽崰鐢?16 bytes --> 瀵硅薄澶?8 bytes) + boolean (1 bytes) + 濉厖鐗╋紙7 bytes锛?/span>

澹版槑浜?涓猙oolean绫诲瀷鍙橀噺鐨勭被锛屽崰鐢?16 bytes --> 瀵硅薄澶?8 bytes) + boolean (1 bytes) * 8

閫氳繃涓婇潰鐨勫疄渚嬶紝鏇存湁鍔╀簬鎴戜滑鐞嗚В銆俕_^

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有