Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337514 - [clean up] Out of memory error while using Source > Cleanup
Summary: [clean up] Out of memory error while using Source > Cleanup
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: performance
Depends on: 150657
Blocks:
  Show dependency tree
 
Reported: 2011-02-17 22:38 EST by Deepak Azad CLA
Modified: 2020-02-22 11:31 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2011-02-17 22:38:04 EST
- On the clean up preference page enable 'Remove unnecessary parentheses' and disable all other clean-ups 
- Select o.e.jdt.core in PE, Source > Clean up
=> I got this out of memory exception. I can try to increase the available memory, but there should not be a problem in the first place as the Clean up does not require more than one AST at a time. 

-------------------------------------------------------------------------------
java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1029)
at org.eclipse.ltk.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:599)
at org.eclipse.ltk.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:438)
at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.computeSuccessorPage(UserInputWizardPage.java:74)
at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:114)
at org.eclipse.jdt.internal.ui.fix.CleanUpRefactoringWizard$CleanUpConfigurationPage.getNextPage(CleanUpRefactoringWizard.java:448)
at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:908)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:428)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3549)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3170)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:181)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:193)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:116)
at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:38)
at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startCleanupRefactoring(RefactoringExecutionStarter.java:251)
at org.eclipse.jdt.internal.ui.actions.AllCleanUpsAction.performRefactoring(AllCleanUpsAction.java:75)
at org.eclipse.jdt.internal.ui.actions.CleanUpAction.runOnMultiple(CleanUpAction.java:203)
at org.eclipse.jdt.internal.ui.actions.CleanUpAction.run(CleanUpAction.java:108)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3549)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3170)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2700)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2664)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2498)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Caused by: java.lang.OutOfMemoryError
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2027)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1665)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1828)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2465)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1834)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2465)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1160)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2441)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2814)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2533)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:532)
at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:183)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2723)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1279)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:876)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:577)
at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:888)
at org.eclipse.jdt.internal.corext.dom.ASTBatchParser.createASTs(ASTBatchParser.java:108)
at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring$CleanUpFixpointIterator.next(CleanUpRefactoring.java:399)
at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.cleanUpProject(CleanUpRefactoring.java:707)
at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.checkFinalConditions(CleanUpRefactoring.java:663)
at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:85)
at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2310)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Root exception:
java.lang.OutOfMemoryError
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2027)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1665)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1828)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2465)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1834)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2465)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1160)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2441)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2814)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2533)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:532)
at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:183)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2723)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1279)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:876)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:577)
at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:888)
at org.eclipse.jdt.internal.corext.dom.ASTBatchParser.createASTs(ASTBatchParser.java:108)
at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring$CleanUpFixpointIterator.next(CleanUpRefactoring.java:399)
at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.cleanUpProject(CleanUpRefactoring.java:707)
at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.checkFinalConditions(CleanUpRefactoring.java:663)
at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:85)
at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2310)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
-----------------------------------------------------------------------------
Comment 1 Dani Megert CLA 2011-02-18 02:34:55 EST
> I can try to increase the available
> memory, but there should not be a problem in the first place as the Clean up
> does not require more than one AST at a time. 
How much memory do you give? Maybe it's failing because of a particular file. Can you check that?
Comment 2 Deepak Azad CLA 2011-02-18 03:14:38 EST
(In reply to comment #1)
> > I can try to increase the available
> > memory, but there should not be a problem in the first place as the Clean up
> > does not require more than one AST at a time. 
> How much memory do you give? Maybe it's failing because of a particular file.
> Can you check that?
Sure, I can take a look. But my first guess was that the exception had something to do with ASTBatchParser and the static initializer block in it.
Comment 3 Markus Keller CLA 2011-02-18 11:57:26 EST
For performance reasons, clean ups create ASTs in batch. Unfortunately, we don't have any way to detect when we're running low on memory (bug 150657), so the best we can do is make an informed guess and hope for the best.

The guesses in ASTBatchParser have been copied from MatchLocator, but it looks like we have to set the limits a bit lower (because we also build DOM ASTs that take more RAM). I've also run into this problem in the past with default VM args (256M) and huge projects.

Deepak, can you please do some tests and adjust the numbers?

E.g. use Runtime.getRuntime().gc() and then print out Runtime.getRuntime().freeMemory() in CleanUpASTRequestor#acceptAST(..) to see how much free memory is left.
Comment 4 Markus Keller CLA 2013-12-16 06:15:29 EST
The ratio is computed with 64MB blocks, and the switch statement maxes out at maxMemory sizes > 256MB. I.e. nowadays, everybody runs with MAX_AT_ONCE, which usually runs out of memory with the default settings.

As a short-term fix, I've released a readable implementation with more realisitc bounds: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=094dcd3dced365d9ffe888c153b364fd20d93111

Manju, please do some experiments to find good bounds. Also test with projects that have many large files (create them yourself or e.g. copy some huge source files like StyledText or jdt.core's Parser).

Also include some performance measurements (using "System.currentTimeMillis()") to find a working set size where adding more CUs to one batch doesn't improve performance any more (or only marginally). Use a real project like jdt.core or jdt.ui for this.

The primary goal is to avoid OutOfMemory problems. Bigger batch sizes only make sense if they improve performance substantially, so if we find that adding more CUs to a batch doesn't win much time, then we better keep smaller batches.
Comment 5 Eclipse Genie CLA 2020-02-22 11:31:16 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.