Java 500M的表放在HashMap裏面大約佔用內存多大?給多大內存最保險?java
運行結果,系統CPU佔用很大,GC全局回收比較厲害。app
GC: Scavenge GC - Reason started: Eden full - parallel with thread number: 8 GC: Scav 7.613 s Since start of previous GC: 7.613 s GC time: 0.572 s Time spent executing application: 7.613 s (93.02%) Object size causing failure: 48 bytes MaxTenure: 7 Eden: 536870912->48/536870912 Survivor: 0->88072136/88080384 (survivor used: 99.99%) Old: 0->410543440/1434451968 (old used: 28.62%) Perm: 10869592->10869592/10911744 GC: Full GC - Reason started: Allocation failure GC: Full 14.852 s Since start of previous GC: 7.239 s GC time: 12.318 s Time spent executing application: 6.667 s (35.12%) **** WARNING: Too much time spent in GC (>20%) Object size causing failure: 40 bytes MaxTenure: 7 Eden: 536870912->40/536870912 Survivor: 88072136->0/88080384 (survivor used: 0.00%) Old: 410543440->1004089160/1434451968 (old used: 70.00%) Perm: 10870672->10870672/10977280 GC: Full GC - Reason started: Allocation failure GC: Full 32.144 s Since start of previous GC: 17.291 s GC time: 9.114 s Time spent executing application: 4.974 s (35.31%) **** WARNING: Too much time spent in GC (>20%) Object size causing failure: 152 bytes MaxTenure: 7 Eden: 536870912->72980680/536870912 Survivor: 0->0/88080384 (survivor used: 0.00%) Old: 1004089160->1434417264/1434451968 (old used: 100.00%) **** WARNING: Sufficient Old Space not reclaimed (<20%)
運行還行。測試
GC: Scavenge GC - Reason started: Eden full - parallel with thread number: 8 GC: Scav 35.977 s Since start of previous GC: 35.977 s GC time: 2.516 s Time spent executing application: 35.977 s (93.46%) Object size causing failure: 32 bytes MaxTenure: 7 Eden: 2147483648->32/2147483648 Survivor: 0->356483168/356515840 (survivor used: 99.99%) Old: 0->1583995632/5729419264 (old used: 27.65%) Perm: 10872000->10872000/10977280 GC: Scavenge GC - Reason started: Eden full - parallel with thread number: 8 GC: Scav 72.401 s Since start of previous GC: 36.424 s GC time: 3.535 s Time spent executing application: 33.908 s (90.56%) Object size causing failure: 104 bytes MaxTenure: 7 Eden: 2147483648->104/2147483648 Survivor: 356483168->356491160/356515840 (survivor used: 99.99%) Old: 1583995632->3541143400/5729419264 (old used: 61.81%) Perm: 10873672->10873672/10977280 $
map's size is 13318240 finshed!, totally used 86229 millionseconds ##處理完成約須要86秒左右
1千萬數據放在內存中,約須要8G啓動堆大小。spa
另外經過此次測試發現 Map 比POJO要更佔用內存。code