Bug 563333 - OutOfMemoryError while building after pulling repositories
Summary: OutOfMemoryError while building after pulling repositories
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.16   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-19 06:21 EDT by Noopur Gupta CLA
Modified: 2020-05-29 18:27 EDT (History)
6 users (show)

See Also:


Attachments
memory_histo_summary.txt (650.38 KB, text/plain)
2020-05-27 03:58 EDT, Noopur Gupta CLA
no flags Details
yourkit screenshot (208.03 KB, image/png)
2020-05-27 15:39 EDT, Andrey Loskutov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2020-05-19 06:21:41 EDT
I20200518-2220

When I switch to a new Eclipse build and open my existing master workspace with it, I do a pull on all repositories after the IDE opens.

Many times when pulling and refreshing/building happens in the IDE, I get OOME and need to exit the workbench.

I am seeing this for almost a month.

It generates many .dmp, .phd, .trc, javacore*.txt files in the eclipse directory which don't seem to have much information.

Let me know if I can provide more details.

Some stack traces from the Error log:

An internal error occurred during: "Building".
java.lang.OutOfMemoryError: Java heap space
	at org.eclipse.jdt.internal.compiler.classfmt.ClassFileStruct.utf8At(ClassFileStruct.java:63)
	at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.decodeCodeAttribute(MethodInfo.java:499)
	at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.readCodeAttribute(MethodInfo.java:472)
...

An internal error occurred during: "Workbench Auto-Save Background Job".
java.lang.OutOfMemoryError: Java heap space
	at java.base/java.util.WeakHashMap.newTable(WeakHashMap.java:195)
	at java.base/java.util.WeakHashMap.resize(WeakHashMap.java:493)
	at java.base/java.util.WeakHashMap.put(WeakHashMap.java:467)
	at org.eclipse.e4.ui.internal.workbench.E4XMIResource.setID(E4XMIResource.java:85)
	at org.eclipse.e4.ui.internal.workbench.E4XMIResource.getID(E4XMIResource.java:109)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.attachedHelper(XMLResourceImpl.java:674)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.attached(ResourceImpl.java:891)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsEList.inverseAdd(ResourceImpl.java:411)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:312)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:304)
	at org.eclipse.e4.ui.internal.workbench.ResourceHandler.createResourceWithApp(ResourceHandler.java:231)
...

Error occurred during status handling
java.lang.OutOfMemoryError: Java heap space
	at org.eclipse.core.internal.runtime.PlatformLogWriter.getLog(PlatformLogWriter.java:68)
	at org.eclipse.core.internal.runtime.Log.log(Log.java:68)
	at org.eclipse.ui.statushandlers.WorkbenchErrorHandler.handle(WorkbenchErrorHandler.java:60)
	at org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler.handle(IDEWorkbenchErrorHandler.java:106)
...

Background Indexer Crash Recovery
java.lang.OutOfMemoryError
	at org.eclipse.jdt.internal.compiler.parser.Scanner.getNextToken0(Scanner.java:1494)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.getNextToken(Scanner.java:1451)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12722)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13033)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12990)
	at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:11384)
	at org.eclipse.jdt.internal.core.search.indexing.SourceIndexer.accept(SourceIndexer.java:132)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:334)
...

LockManager.handleException
java.lang.Exception
	at org.eclipse.core.internal.jobs.LockManager.createDebugException(LockManager.java:175)
	at org.eclipse.core.internal.jobs.LockManager.removeLockCompletely(LockManager.java:253)
	at org.eclipse.core.internal.jobs.WorkerPool.endJob(WorkerPool.java:115)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:83)
Caused by: java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:372)
	at java.base/java.util.ArrayList.get(ArrayList.java:458)
	at org.eclipse.core.internal.jobs.DeadlockDetector.lockReleasedCompletely(DeadlockDetector.java:385)
	at org.eclipse.core.internal.jobs.LockManager.removeLockCompletely(LockManager.java:251)
	... 2 more

An internal error occurred during: "Computing Git status for repository eclipse.pde.ui".
java.lang.OutOfMemoryError: Java heap space
	at java.base/sun.nio.fs.WindowsNativeDispatcher.FindFirstFile0(Native Method)
	at java.base/sun.nio.fs.WindowsNativeDispatcher.FindFirstFile(WindowsNativeDispatcher.java:185)
	at java.base/sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:78)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:519)
	at java.base/java.nio.file.Files.newDirectoryStream(Files.java:471)
	at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:300)
	at java.base/java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
	at java.base/java.nio.file.Files.walkFileTree(Files.java:2716)
	at org.eclipse.jgit.util.FS_Win32.list(FS_Win32.java:104)
	at org.eclipse.jgit.treewalk.FileTreeIterator.entries(FileTreeIterator.java:212)
...
Comment 1 Andrey Loskutov CLA 2020-05-19 09:49:02 EDT
Noopur, I assume that this could be related to jgit memory usage, but better we check this with memory dump.

First get your Eclipse process id (jps -l).
With process_id you can then create 3 files that could help:

jmap -heap process_id > /tmp/memory_heap_summary.txt
jmap -histo process_id > /tmp/memory_histo_summary.txt
 
# this will take longer and can require lot of free disk space (depending on the config from ~2 to ~20 GB)!
jmap -dump:file=/tmp/memory_dump.hprof process_id

# Zip all and attach to this bug:
zip memory_dump.zip /tmp/memory_heap_summary.txt /tmp/memory_histo_summary.txt /tmp/memory_dump.hprof
Comment 2 Noopur Gupta CLA 2020-05-20 05:20:09 EDT
I am using AdoptOpenJDK\jdk-11.0.4.11-openj9 as the default on my windows system and running these commands with -heap and -dump gives the message:

exactly one option must be selected
jmap: obtain heap information about a Java process
 Usage:
    jmap <option>* <vmid>
        <vmid>: Attach API VM ID as shown in jps or other Attach API-based tools
        <vmid>s are read from stdin if none are supplied as arguments
    -histo: print statistics about classes on the heap, including number of objects and aggregate size
    -histo:live : Print only live objects
    -J: supply arguments to the Java VM running jmap
NOTE: this utility may significantly affect the performance of the target VM.
At least one option must be selected.
Comment 3 Andrey Loskutov CLA 2020-05-20 05:28:35 EDT
(In reply to Noopur Gupta from comment #2)
> I am using AdoptOpenJDK\jdk-11.0.4.11-openj9 as the default on my windows
> system and running these commands with -heap and -dump gives the message:
> 
> exactly one option must be selected
> jmap: obtain heap information about a Java process
>  Usage:
>     jmap <option>* <vmid>
>         <vmid>: Attach API VM ID as shown in jps or other Attach API-based
> tools
>         <vmid>s are read from stdin if none are supplied as arguments
>     -histo: print statistics about classes on the heap, including number of
> objects and aggregate size
>     -histo:live : Print only live objects
>     -J: supply arguments to the Java VM running jmap
> NOTE: this utility may significantly affect the performance of the target VM.
> At least one option must be selected.

But how did you run it? 

I wrote all the commands with only one argument:

jmap -heap process_id > /tmp/memory_heap_summary.txt
jmap -histo process_id > /tmp/memory_histo_summary.txt
jmap -dump:file=/tmp/memory_dump.hprof process_id
Comment 4 Andrey Loskutov CLA 2020-05-20 05:33:33 EDT
(In reply to Andrey Loskutov from comment #3)
> But how did you run it? 
> 
> I wrote all the commands with only one argument:
> 
> jmap -heap process_id > /tmp/memory_heap_summary.txt
> jmap -histo process_id > /tmp/memory_histo_summary.txt
> jmap -dump:file=/tmp/memory_dump.hprof process_id

Of course if you have Windows, you can't use output redirection, so you must copy/paste the output manually 

jmap -heap process_id
# copy std out to memory_heap_summary.txt

jmap -histo process_id 
# copy std out to memory_histo_summary.txt

jmap -dump:file=C:\tmp\memory_dump.hprof process_id

Not sure regarding the last one, what is the supported path notation on windows JDK.
Comment 5 Noopur Gupta CLA 2020-05-20 05:42:08 EDT
I ran the following (9880 is the process id):

jmap -heap 9880 > C:\tmp\memory_heap_summary.txt
jmap -histo 9880 > C:\tmp\memory_histo_summary.txt
jmap -dump:file=C:\tmp\memory_dump.hprof 9880

Only the one with -histo worked. The other two gave the message that I pasted. Probably -heap and -dump are not supported in AdoptOpenJDK\jdk-11.0.4.11-openj9. 

I will try with another JDK when the OOME happens.
Comment 6 Andrey Loskutov CLA 2020-05-20 05:49:01 EDT
(In reply to Noopur Gupta from comment #5)
> I ran the following (9880 is the process id):
> 
> jmap -heap 9880 > C:\tmp\memory_heap_summary.txt
> jmap -histo 9880 > C:\tmp\memory_histo_summary.txt
> jmap -dump:file=C:\tmp\memory_dump.hprof 9880
> 
> Only the one with -histo worked. The other two gave the message that I
> pasted. Probably -heap and -dump are not supported in
> AdoptOpenJDK\jdk-11.0.4.11-openj9. 
> 
> I will try with another JDK when the OOME happens.

Try with

jcmd 9880 GC.class_histogram
jcmd 9880 GC.heap_dump C:\tmp\memory_dump.hprof
Comment 7 Noopur Gupta CLA 2020-05-20 06:02:26 EDT
(In reply to Andrey Loskutov from comment #6)
> Try with
> 
> jcmd 9880 GC.class_histogram
> jcmd 9880 GC.heap_dump C:\tmp\memory_dump.hprof

Thanks, these are working. 

Now the OOME is not happening with the same steps, probably because there is nothing to merge after pulling as I just pulled them earlier. I will get the files next time.
Comment 8 Noopur Gupta CLA 2020-05-27 03:58:58 EDT
Created attachment 283033 [details]
memory_histo_summary.txt

I got OOME in I20200526-1800 while building after pulling the repositories.

Attaching memory_histo_summary.txt. The other file memory_dump.hprof is 2GB and Bugzilla won't allow it as an attachment. I will share the link after uploading it to some other location.
Comment 9 Noopur Gupta CLA 2020-05-27 04:52:20 EDT
(In reply to Noopur Gupta from comment #8)
> The other file memory_dump.hprof is 2GB
> and Bugzilla won't allow it as an attachment. I will share the link after
> uploading it to some other location.

https://www.dropbox.com/s/5lo99kwwavi9zf4/memory_dump.hprof?dl=0
Comment 10 Andrey Loskutov CLA 2020-05-27 15:39:46 EDT
Created attachment 283037 [details]
yourkit screenshot

(In reply to Noopur Gupta from comment #8)
> Created attachment 283033 [details]
> memory_histo_summary.txt
> 
> I got OOME in I20200526-1800 while building after pulling the repositories.
> 
> Attaching memory_histo_summary.txt. The other file memory_dump.hprof is 2GB
> and Bugzilla won't allow it as an attachment. I will share the link after
> uploading it to some other location.

 num     #instances         #bytes  class name (module)
-------------------------------------------------------
   1:        177218     1011760960  [I (java.base@13)
   2:       2494674      637787576  [B (java.base@13)

You have 1 GB with array of ints and 600 MB in arrays bytes, all retained by jgit pack files, see screenshot.

I would recommend to increase heap size or reduce number of projects in your workspace :-). 

I run with 16 GB and pretty much of SDK imported without issues, but 8 should be OK too.
Comment 11 Noopur Gupta CLA 2020-05-28 02:43:12 EDT
(In reply to Andrey Loskutov from comment #10)
> Created attachment 283037 [details]
> yourkit screenshot
> 
> You have 1 GB with array of ints and 600 MB in arrays bytes, all retained by
> jgit pack files, see screenshot.
> 
> I would recommend to increase heap size or reduce number of projects in your
> workspace :-). 
> 
> I run with 16 GB and pretty much of SDK imported without issues, but 8
> should be OK too.

Thanks for looking into it. I use the default 2 GB but started seeing this with the same number of projects almost 1-2 months back. I will increase the heap size and report if it happens again.
Comment 12 Andrey Loskutov CLA 2020-05-28 03:02:09 EDT
(In reply to Noopur Gupta from comment #11)
> Thanks for looking into it. I use the default 2 GB but started seeing this
> with the same number of projects almost 1-2 months back.

Which egit version are you using? May be we had a regression in jgit/egit area.
Comment 13 Noopur Gupta CLA 2020-05-28 03:24:00 EDT
(In reply to Andrey Loskutov from comment #12)
> Which egit version are you using? 

Git integration for Eclipse	5.7.0.202003110725-r
Comment 14 Lars Vogel CLA 2020-05-28 03:28:03 EDT
Should this bug moved to JGit or EGit?
Comment 15 Thomas Wolf CLA 2020-05-29 18:27:12 EDT
@Matthias: could this be caused by https://git.eclipse.org/r/#/c/155149/ ? I'm particularly wary of the fact the the soft reference queue's enqueue() has been overridden to be a no-op. Previously when there was also only soft references and a ReferenceQueue, calling Ref.enqueue() _did_ enqueue the item, and a subequent WindowCache.gc() would find it on the queue. Newly PageRef.kill() will not actually enqueue the ref; that'll happen only later, whenever the Java GC feels up to it.