{"id":2729,"date":"2022-08-30T15:27:17","date_gmt":"2022-08-30T15:27:17","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/08\/problem-about-linkedhashmap-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:27:17","modified_gmt":"2022-08-30T15:27:17","slug":"problem-about-linkedhashmap-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-linkedhashmap-collection-of-common-programming-errors\/","title":{"rendered":"problem about linkedhashmap-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1dbca32ea269fb14931fbbae09922316?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPassionate programmer<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/06c34f500f052879492e66d40c5d60d8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nweakwire<br \/>\njava android serialization linkedhashmap<br \/>\nSo i want to pass a LinkedHashMap to an intent.\/\/SEND THE MAP Intent singlechannel = new Intent(getBaseContext(),singlechannel.class); singlechannel.putExtra(&#8220;db&#8221;,shows1);\/\/perase to startActivity(singlechannel);\/\/GET THE MAP LinkedHashMap&lt;String,String&gt; db = new LinkedHashMap&lt;String,String&gt;(); db=(LinkedHashMap&lt;String,String&gt;) getIntent().getSerializableExtra(&#8220;db&#8221;);This one Worked Like a charm with HashMap. But with LinkedHashMap i got a problem i got a runtime error heredb<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4d008a66b2c3feca2bbd8ba6fd070786?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNearalias<br \/>\njava runtime implementation linkedhashmap<br \/>\nSo I&#8217;ve looked around a little and couldn&#8217;t really find any straight up answer for this. Personally I&#8217;m guessing Java probably manipulates timestamp on the items inserted into the LinkedHashMap, and possibly uses that in its ordering somehow.I know that all the removeEldestEntry needs to do is simply returning true\/false, but then when it gets to actually removing the eldest entry from the map, it would seem like the runtime would be O(n), what is it really?Thanks.<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/37832b32968085af74919b1bedc9d74a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nwziska<br \/>\njava caching memory-leaks linkedhashmap<br \/>\nI&#8217;m trying to use LinkedHashMap as a local FIFO cache solution overwriting its removeEldestEntry method to keep size fixed:Map lhm = new LinkedHashMap(MAX_CACHE_SIZE + 1, .75F, false) {protected boolean removeEldestEntry(Map.Entry eldest) {return size() &gt; MAX_CACHE_SIZE;} };but when I constantly add new entries to the map monitoring process memory I see it keeps growing until max virtual machine memory is used though map size doesn&#8217;t increase.Is it by design? Why does it need more memory if o<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2014-02-08 03:36:29. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Passionate programmer weakwire java android serialization linkedhashmap So i want to pass a LinkedHashMap to an intent.\/\/SEND THE MAP Intent singlechannel = new Intent(getBaseContext(),singlechannel.class); singlechannel.putExtra(&#8220;db&#8221;,shows1);\/\/perase to startActivity(singlechannel);\/\/GET THE MAP LinkedHashMap&lt;String,String&gt; db = new LinkedHashMap&lt;String,String&gt;(); db=(LinkedHashMap&lt;String,String&gt;) getIntent().getSerializableExtra(&#8220;db&#8221;);This one Worked Like a charm with HashMap. But with LinkedHashMap i got a problem i got a runtime error [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2729","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2729"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2729\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}