This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I am using a dev build from Jan 25. In recent dev builds I have noticed huge memory usage; >1Gb heap is typical after daily use, and it never really goes down, even if all projects are closed and content-specific windows like Find Usages are closed. After taking a heap dump I found hundreds of megabytes of strings that seem to be from diff views, which seemed to be held via `AnnotationHolder.openedComponents` as well as `file2Holder`. For example, a string representing the name of a Git remote ref in a project I have not had open for quite some time: this - value: java.lang.String #1373501 <- branchName - class: org.netbeans.modules.git.ui.repository.Revision$BranchReference, value: java.lang.String #1373501 <- [467] - class: java.lang.Object[], value: org.netbeans.modules.git.ui.repository.Revision$BranchReference #9579 <- elementData - class: java.util.Vector, value: java.lang.Object[] #577228 <- objects - class: javax.swing.DefaultComboBoxModel, value: java.util.Vector #8040 <- dataModel - class: javax.swing.JComboBox, value: javax.swing.DefaultComboBoxModel #197 <- cmbDiffTreeSecond - class: org.netbeans.modules.git.ui.diff.MultiDiffPanel, value: javax.swing.JComboBox #217 <- parent - class: javax.swing.JSplitPane, value: org.netbeans.modules.git.ui.diff.MultiDiffPanel #45 <- parent - class: org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView$1, value: javax.swing.JSplitPane #123 <- view - class: org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView, value: org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView$1 #71 <- master - class: org.netbeans.modules.diff.builtin.visualizer.editable.DiffContentPanel, value: org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView #71 <- master - class: org.netbeans.modules.diff.builtin.visualizer.editable.DecoratedEditorPane, value: org.netbeans.modules.diff.builtin.visualizer.editable.DiffContentPanel #142 <- key - class: java.util.HashMap$Node, value: org.netbeans.modules.diff.builtin.visualizer.editable.DecoratedEditorPane #142 <- [13] - class: java.util.HashMap$Node[], value: java.util.HashMap$Node #1115090 <- table - class: java.util.HashMap, value: java.util.HashMap$Node[] #195872 <- map - class: java.util.HashSet, value: java.util.HashMap #272144 <- openedComponents - class: org.netbeans.modules.editor.hints.AnnotationHolder, value: java.util.HashSet #45729 <- value - class: java.util.HashMap$Node, value: org.netbeans.modules.editor.hints.AnnotationHolder #31 <- [38] - class: java.util.HashMap$Node[], value: java.util.HashMap$Node #1083138 <- table - class: java.util.HashMap, value: java.util.HashMap$Node[] #106870 <- file2Holder - class: org.netbeans.modules.editor.hints.AnnotationHolder, value: java.util.HashMap #35394
Adding PERFORMANCE keyword since I see nothing related to heap usage specifically.
Created attachment 163510 [details] Possible fix (not yet tested)
Another bad reference which puts more of the blame on `file2Holder`: this - value: org.netbeans.lib.lexer.token.DefaultToken #142002 <- [1733] - class: java.lang.Object[], value: org.netbeans.lib.lexer.token.DefaultToken #142002 <- elementData - class: org.netbeans.lib.lexer.inc.IncTokenList, value: java.lang.Object[] #272130 <- rootTokenList - class: org.netbeans.lib.lexer.TokenHierarchyOperation, value: org.netbeans.lib.lexer.inc.IncTokenList #90 <- operation - class: org.netbeans.spi.lexer.TokenHierarchyControl, value: org.netbeans.lib.lexer.TokenHierarchyOperation #92 <- thc - class: org.netbeans.lib.lexer.inc.DocumentInput, value: org.netbeans.spi.lexer.TokenHierarchyControl #90 <- value - class: java.util.Hashtable$Entry, value: org.netbeans.lib.lexer.inc.DocumentInput #90 <- [47] - class: java.util.Hashtable$Entry[], value: java.util.Hashtable$Entry #74934 <- table - class: org.netbeans.modules.editor.NbEditorDocument$4, value: java.util.Hashtable$Entry[] #4463 <- documentProperties - class: org.netbeans.modules.csl.core.GsfDocument, value: org.netbeans.modules.editor.NbEditorDocument$4 #89 <- doc - class: org.netbeans.modules.editor.hints.AnnotationHolder, value: org.netbeans.modules.csl.core.GsfDocument #5 <- value - class: java.util.HashMap$Node, value: org.netbeans.modules.editor.hints.AnnotationHolder #19 <- next - class: java.util.HashMap$Node, value: java.util.HashMap$Node #735218 <- [20] - class: java.util.HashMap$Node[], value: java.util.HashMap$Node #722852 <- table - class: java.util.HashMap, value: java.util.HashMap$Node[] #106870 <- file2Holder - class: org.netbeans.modules.editor.hints.AnnotationHolder, value: java.util.HashMap #35394 Probably the use of `WeakHashMap` here is futile due to the `od` and `file` fields (oddly not `final`), which suggests that `clearAll` is not getting called often enough, perhaps because `resolveAllComponents` is buggy. Or perhaps `EditorRegistry.componentList` is returning long-closed editor tabs? Perhaps because the use of a `HashSet` for `openedComponents` caused these tabs to be retained? Hard to follow what the root cause is here.
Have been running with this patch and so far memory usage seems much better. Hard to be sure since I do not know how to reproduce the problem from scratch.
The problem is not solved with this patch. After closing all projects and every project-related window, memory usage remained high, and in a dump I found the *complete text* of a file I had been editing the day before, held via org.netbeans.modules.editor.lib2.document.ContentEdit$InsertEdit.text org.netbeans.modules.editor.NbEditorDocument.lastModifyUndoEdit org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView.modifiedDocument org.netbeans.modules.diff.builtin.visualizer.editable.DiffContentPanel.master org.netbeans.modules.diff.builtin.visualizer.editable.DecoratedEditorPane.master org.netbeans.editor.BaseTextUI.editor org.netbeans.editor.BaseDocument$OldListenerAdapter.delegate javax.swing.event.EventListenerList.listenerList org.netbeans.modules.editor.NbEditorDocument.listenerList org.netbeans.modules.editor.hints.AnnotationHolder.doc java.util.WeakHashMap$Entry.value java.util.WeakHashMap$Entry chunk.next java.util.WeakHashMap.table org.netbeans.modules.editor.hints.AnnotationHolder.file2Holder