Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: java8 up to 6x slower than java7 Date: Mon, 17 Feb 2014 18:55:03 +0100 Lines: 35 Message-ID: References: <29a51a94-8f9a-41b1-980f-e8c13e2d11a2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net ypshs89f2yggM9Sjs2ThgQCAzdAQHNvRTAjy26VBOfYi7nEQY= Cancel-Lock: sha1:CQkstbZ7bzGCe9lYEiEmvf7XvQs= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:27534 On 16.02.2014 20:36, Jan Burse wrote: > Jan Burse schrieb: >> So the requirement was really to have very light weighted hash >> maps for this data structure. Even if there is a small time overhead. >> Problem was that application crashed without compaction, since >> memory consumption was too high. > > The requirement is that the following code should > eat up O(m) space and not O(m*n) space: > > HashMap[] maps = new HashMap[m]; > for (int i=0; i maps = new HashMap(); > } > for (int i=0; i for (int j=0; j maps[i].put(j,j) > } > for (int j=0; j maps[i].remove(j); > } > } What is n here? Is that some arbitrary input figure otherwise unrelated to the shown code? A small change which would help this code and avoid too much overhead is to set the table to null once the Map is empty. Since all your Maps are empty at the end this would help dramatically. Cheers robert