This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 402912 - OutOfMemoryError when eclipse left overnight
Summary: OutOfMemoryError when eclipse left overnight
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: PC Linux
: P3 critical (vote)
Target Milestone: 4.3 M7   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
: 407139 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-03-11 10:22 EDT by Paul Webster CLA
Modified: 2013-05-17 10:37 EDT (History)
13 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Webster CLA 2013-03-11 10:22:31 EDT
I've noticed OutOfMemoryErrors when I come in some mornings.

I'm going to try some profiling, to see if I can narrow down what's doing this.

PW
Comment 1 Eric Moffatt CLA 2013-03-14 15:33:28 EDT
I think I'm right at the edge now...my mem usage is at 491 of 495 and my performance has dropped *significantly*...

IMO we should fix this before M6 goes out since the optics (i.e. flame-fest) would be potentially quite damaging.
Comment 2 David Williams CLA 2013-03-15 13:03:13 EDT
I agree there seems to be a problem here. I did a fresh install, opened an empty workbench, and let it sit except for starting the "heap display", and overnight saw the memory use increase by a factor of 2 or 3. (2, on linux, nearly 3 on windows). 

This morning I set max heap real low (60 g), and got an our of memory error after it just sat for 2 or 3 hours. I took a peek at the heap dump (using MAT) and unfortunately nothing obviously jumped out, to me. Something that's going to take some study. 

In other words, think we'll have to live with it for M6, unless someone is busy tracking this down?
Comment 3 Paul Webster CLA 2013-03-15 13:47:35 EDT
We have been looking at it, but haven't been able to track it to something specific yet and will have to continue our analysis in M7

PW
Comment 4 Paul Webster CLA 2013-03-19 10:36:43 EDT
Bogdan has tracked it down to the new workbench-auto-save feature, Bug 2369.  It clones a model and then uses an EMF Resource to write it out.  But that leaves the Resource (with the entire cloned model) in the ResourceSet.  It needs to be unloaded and removed.

PW
Comment 5 Paul Webster CLA 2013-03-19 10:48:30 EDT
I've pushed a fix as https://git.eclipse.org/r/#/c/11311/

PW
Comment 6 Paul Webster CLA 2013-03-19 10:49:38 EDT
The workaround for M6 is to set the Preferences>General>"Workbench save interval" to 0, which disables it.

PW
Comment 7 Thomas Schindl CLA 2013-03-19 10:51:38 EDT
Does resource.unload() really work? Why are we creating the resource through the ResourceSet instead of simply creating an instance ourselves?
Comment 8 Paul Webster CLA 2013-03-19 10:57:15 EDT
The resourceSet.getResources().remove(*) works, and prevents the number of resources from growing in the resource set (which is the current leak).

As for the why, it's because that method exists.  Why, do you think it just creating a ResourceSetImpl() inline would work?  Our own ResourceSetImpl is pre-configured with a lot of stuff: org.eclipse.e4.ui.internal.workbench.ResourceHandler.init()

PW
Comment 9 Paul Webster CLA 2013-03-19 15:18:32 EDT
I've released the fix as http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=518a06e4208a966fa0644ba2a55163310dd22a09 for now.

I've confirmed that with the fix, we don't accumulate model copies.  We're going to run our OOME test overnight again with the fix to confirm.

PW
Comment 10 Paul Webster CLA 2013-03-20 23:08:35 EDT
Clearing the resources removed the major memory leak (150Meg over 48 hours).

PW
Comment 11 Stephan Herrmann CLA 2013-03-21 10:43:15 EDT
(In reply to comment #6)
> The workaround for M6 is to set the Preferences>General>"Workbench save
> interval" to 0, which disables it.
> 
> PW

Tried that, but "Value must be an Integer between 1 and 9,999"
Comment 12 Dani Megert CLA 2013-03-21 10:47:44 EDT
(In reply to comment #11)
> (In reply to comment #6)
> > The workaround for M6 is to set the Preferences>General>"Workbench save
> > interval" to 0, which disables it.
> > 
> > PW
> 
> Tried that,

I'd bet you did not ;-). You probably tried to change the similar value on the on the "Workbench" preference page.
Comment 13 Paul Webster CLA 2013-03-21 10:48:56 EDT
(In reply to comment #11)
> Tried that, but "Value must be an Integer between 1 and 9,999"

Make sure you're on the General preference page (I think Workspace has something that looks similar, but it's about workspace not workbench)

PW
Comment 14 Stephan Herrmann CLA 2013-03-21 11:11:41 EDT
Yes, both of you are right, I tried
  "Workspace save interval (in minutes):"
where I should've used
  "Workbench save interval (in minutes):"

I have a sense of an inkling that this will not be the last false alarm
in this matter ...

And then: why does one accept 0 where the other does not?
Comment 15 Dani Megert CLA 2013-03-21 11:13:24 EDT
(In reply to comment #14)
> And then: why does one accept 0 where the other does not?

We planned for this bug ;-)
Comment 16 Bogdan Gheorghe CLA 2013-03-22 18:31:56 EDT
Verified the fix from Comment 9. Left the profiler running for 36 hours - no more more memory growth.
Comment 17 Paul Webster CLA 2013-03-28 15:17:58 EDT
*** Bug 404588 has been marked as a duplicate of this bug. ***
Comment 18 Snjezana Peco CLA 2013-04-10 09:26:21 EDT
There are two issues related to this functionality:

1) If you set the interval to 0, you won't be able to change it without restarting the workspace because the autoSaveJob isn't created (if the preference is set when starting Eclipse) or isn't rescheduled (if it is set to 0 using the General preferences page).

2) If the interval != 0, Eclipse starts the autoSaveJob job that runs forever. There isn't any such a job in Eclipse and this breaks our tests. See https://github.com/jbosstools/jbosstools-base/blob/master/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/JobUtils.java and https://issues.jboss.org/browse/JBIDE-13973

I suppose this has to be run in a separate thread that is always created, sleeps for saveInterval ms (or some constant interval if saveInterval=0) and, after that, calls persist in a new job if saveInterval>0.

Also, I suppose this preference would have to be 0 by default because that is behaviour users expect. This would also speed up tests that don't test this preference.
Comment 19 Dani Megert CLA 2013-04-10 09:46:56 EDT
(In reply to comment #18)
> There are two issues related to this functionality:
> 
> 1) If you set the interval to 0, you won't be able to change it without
> restarting the workspace because the autoSaveJob isn't created (if the
> preference is set when starting Eclipse) or isn't rescheduled (if it is set
> to 0 using the General preferences page).
> 
> 2) If the interval != 0, Eclipse starts the autoSaveJob job that runs
> forever. There isn't any such a job in Eclipse and this breaks our tests.
> See
> https://github.com/jbosstools/jbosstools-base/blob/master/tests/plugins/org.
> jboss.tools.tests/src/org/jboss/tools/test/util/JobUtils.java and
> https://issues.jboss.org/browse/JBIDE-13973
> 
> I suppose this has to be run in a separate thread that is always created,
> sleeps for saveInterval ms (or some constant interval if saveInterval=0)
> and, after that, calls persist in a new job if saveInterval>0.
> 
> Also, I suppose this preference would have to be 0 by default because that
> is behaviour users expect. This would also speed up tests that don't test
> this preference.

Please file a separate bug report.
Comment 20 Snjezana Peco CLA 2013-04-10 09:53:00 EDT
I have created #405356
Comment 21 Thomas Schindl CLA 2013-05-07 04:07:22 EDT
*** Bug 407139 has been marked as a duplicate of this bug. ***
Comment 22 Paul Webster CLA 2013-05-17 10:37:50 EDT
in 4.3.0.I20130516-2200

PW