久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

多地圖空間問(wèn)題:番石榴

Multimap Space Issue: Guava(多地圖空間問(wèn)題:番石榴)
本文介紹了多地圖空間問(wèn)題:番石榴的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

在我的 Java 代碼中,我使用 Guava 的 Multimap (com.google.common.collect.Multimap) 使用這個(gè):

In my Java code, I am using Guava's Multimap (com.google.common.collect.Multimap) by using this:

 Multimap<Integer, Integer> Index = HashMultimap.create()

這里,Multimap 鍵是 URL 的一部分,值是 URL 的另一部分(轉(zhuǎn)換為整數(shù)).現(xiàn)在,我分配我的 JVM 2560 Mb (2.5 GB) 堆空間(通過(guò)使用 Xmx 和 Xms).但是,它只能存儲(chǔ) 900 萬(wàn)個(gè)這樣的(鍵、值)整數(shù)對(duì)(大約 1000 萬(wàn)個(gè)).但是,理論上(根據(jù) int 占用的內(nèi)存)它應(yīng)該存儲(chǔ)更多.

Here, Multimap key is some portion of a URL and value is another portion of the URL (converted into an integer). Now, I assign my JVM 2560 Mb (2.5 GB) heap space (by using Xmx and Xms). However, it can only store 9 millions of such (key,value) pairs of integers (approx 10 million). But, theoretically (according to memory occupied by int) it should store more.

誰(shuí)能幫幫我,

  1. 為什么 Multimap 使用大量?jī)?nèi)存?我檢查了我的代碼,沒(méi)有在 Multimap 中插入對(duì),它只使用了 1/2 MB 的內(nèi)存.
  2. 2.
  1. Why is Multimap using lots of memory? I checked my code and without inserting pairs into the Multimap, it only uses 1/2 MB of memory.
  2. 2.

是否有另一種方法或自制的解決方案來(lái)解決這個(gè)內(nèi)存問(wèn)題?意思是,有沒(méi)有辦法減少這些對(duì)象開(kāi)銷(xiāo),因?yàn)槲抑幌氪鎯?chǔ) int-int?在任何其他語(yǔ)言?或任何其他解決方案(首選自制)來(lái)解決我面臨的問(wèn)題,意味著基于數(shù)據(jù)庫(kù)或類(lèi)似的解決方案.

Is there another way or home-baked solution to solve this memory issue? Means, Is there any way to reduce those object overheads as I want to store only int-int? In any other language ? Or any other solution (home-baked preferred) to solve issue I faced, means DB based or something like that solution.

推薦答案

Multimap 相關(guān)的開(kāi)銷(xiāo)很大.至少:

There's a huge amount of overhead associated with Multimap. At a minimum:

  • 每個(gè)鍵和值都是一個(gè) Integer 對(duì)象,它(至少)使每個(gè) int 值的存儲(chǔ)需求翻倍.
  • HashMultimap 中的每個(gè)唯一鍵值都與一個(gè) Collection 值相關(guān)聯(lián)(根據(jù) 來(lái)源,Collection哈希集).
  • 每個(gè) Hashset 都使用 8 個(gè)值的默認(rèn)空間創(chuàng)建.
  • Each key and value is an Integer object, which (at a minimum) doubles the storage requirements of each int value.
  • Each unique key value in the HashMultimap is associated with a Collection of values (according to the source, the Collection is a Hashset).
  • Each Hashset is created with default space for 8 values.

因此,每個(gè)鍵/值對(duì)(至少)需要的空間可能比您對(duì)兩個(gè) int 值的預(yù)期多一個(gè)數(shù)量級(jí).(當(dāng)多個(gè)值存儲(chǔ)在一個(gè)鍵下時(shí)會(huì)少一些.)我預(yù)計(jì) 1000 萬(wàn)個(gè)鍵/值對(duì)可能占用 400MB.

So each key/value pair requires (at a minimum) perhaps an order of magnitude more space than you might expect for two int values. (Somewhat less when multiple values are stored under a single key.) I would expect 10 million key/value pairs to take perhaps 400MB.

雖然您有 2.5GB 的堆空間,但如果這還不夠,我也不會(huì)感到驚訝.我認(rèn)為,上述估計(jì)偏低.此外,它僅說(shuō)明地圖構(gòu)建后需要存儲(chǔ)多少.隨著映射的增長(zhǎng),表需要重新分配和重新散列,這暫時(shí)至少使使用的空間量增加一倍.最后,所有這些都假設(shè) int 值和對(duì)象引用需要 4 個(gè)字節(jié).如果 JVM 使用 64 位尋址,字節(jié)數(shù)可能會(huì)翻倍.

Although you have 2.5GB of heap space, I wouldn't be all that surprised if that's not enough. The above estimate is, I think, on the low side. Plus, it only accounts for how much is needed to store the map once it is built. As the map grows, the table needs to be reallocated and rehashed, which temporarily at least doubles the amount of space used. Finally, all this assumes that int values and object references require 4 bytes. If the JVM is using 64-bit addressing, the byte count probably doubles.

這篇關(guān)于多地圖空間問(wèn)題:番石榴的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Convert List of Strings into Map using Java-8 Streams API(使用 Java-8 Streams API 將字符串列表轉(zhuǎn)換為 Map)
Getting data from JSON(從 JSON 獲取數(shù)據(jù))
java linkedhashmap iteration(javalinkedhashmap迭代)
Converting a list of objects to Map(將對(duì)象列表轉(zhuǎn)換為 Map)
Create a HashMap with a fixed Key corresponding to a HashSet. point of departure(用一個(gè)固定的Key對(duì)應(yīng)一個(gè)HashSet創(chuàng)建一個(gè)HashMap.出發(fā)點(diǎn))
HttpMessageConverter exception : RestClientException: Could not write request: no suitable HttpMessageConverter found(HttpMessageConverter 異常:RestClientException:無(wú)法寫(xiě)入請(qǐng)求:找不到合適的 HttpMessageConverter) - IT屋-程序員
主站蜘蛛池模板: 欧美精品被 | 久久精品色欧美aⅴ一区二区 | 国产欧美日韩综合精品一区二区 | 精品视频一区二区三区在线观看 | 日韩免费av网站 | 色综合欧美 | 欧美a级成人淫片免费看 | 色婷婷精品 | 国产小视频在线 | 一区二区日韩精品 | 久久骚| 91在线精品一区二区 | 在线中文字幕亚洲 | 青青久草 | 草在线 | 91视频进入 | 一区二区三区中文字幕 | 日本特黄a级高清免费大片 特黄色一级毛片 | 日日夜夜91 | 久草网在线视频 | 国产一区二区在线播放视频 | 久久不卡| 日本一区视频在线观看 | 在线观看 亚洲 | 国产一在线观看 | 中文字幕视频网 | 国产精品久久久亚洲 | 99成人| av天天干 | 免费国产一区二区视频 | 亚洲视频三区 | h视频在线观看免费 | 99久久婷婷国产综合精品首页 | 日韩欧美国产一区二区 | 亚洲欧美精品 | 久久久蜜臀国产一区二区 | 久久99精品久久久久蜜桃tv | 美女毛片免费看 | 一级毛片高清 | 久久久精品一区 | 久久久无码精品亚洲日韩按摩 |