| Summary: | OOM in HashtableOfObject: Requested array size exceeds VM limit | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Andrey Loskutov <loskutov> |
| Component: | Core | Assignee: | Andrey Loskutov <loskutov> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jkubitz-eclipse, sravankumarl |
| Version: | 4.12 | ||
| Target Milestone: | 4.23 M2 | ||
| Hardware: | PC | ||
| OS: | All | ||
| See Also: |
https://bugs.eclipse.org/bugs/show_bug.cgi?id=474323 https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/189648 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=d041f3803d811a0e9790d305639e77e557feceab https://bugs.eclipse.org/bugs/show_bug.cgi?id=569069 |
||
| Whiteboard: | |||
|
Description
Andrey Loskutov
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/189648 Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/189648 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=d041f3803d811a0e9790d305639e77e557feceab (In reply to Andrey Loskutov from comment #0) > Two things: > 1) I can't see which file causes it, I can't check this file Error handling / logging improved > 2) May be a trivial size check could be added? Size checks / calculation of the next table size improved / tests added documenting current expectations / limitations. Ideally we should simply throw away HashtableOfObject (& Co) and replace it with HashMap, similar to the work done in bug 569069. *** Bug 474323 has been marked as a duplicate of this bug. *** > java.lang.OutOfMemoryError: Requested array size exceeds VM limit
Such error can happen before Integer.MAX_VALUE-2.
see:
java.io.InputStream.MAX_BUFFER_SIZE,
java.util.Hashtable.MAX_ARRAY_SIZE
/**
* The maximum size of array to allocate.
* Some VMs reserve some header words in an array.
* Attempts to allocate larger arrays may result in
* OutOfMemoryError: Requested array size exceeds VM limit
*/
private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8;
also
int extraRoom = (int) (size * 1.75f);
could already overflow.
however i wonder how that many objects are stored in the map. Even if only half of maximum number of objects caused that error. 1_000_000_000 objects sounds implausible many. that file would have to be gigantic. To me it sound more like the saved file was corrupted so that the wrong amount of objects was tried to read.
Verified in Eclipse SDK Version: 2022-03 (4.23) Build id: I20220215-1800 OS: Windows 10, v.10.0, x86_64 / win32 Java vendor: Eclipse Adoptium Java runtime version: 17.0.1+12 Java version: 17.0.1 |