gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.52k stars 374 forks source link

Eclipse plugin leaves a large number temporary files (can result in very slow Eclipse startup) #5260

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 5261

Found in GWT Release (e.g. 1.5.3, 1.6 RC):
Google Plugin for Eclipse 3.6, 1.3.3.v201006111317 + GWT 2.0.3
also seen in Google Plugin for Eclipse 3.5 and latest version of plugin.

Encountered on OS / Browser (e.g. WinXP, IE6-7, FF3):
Windows XP SP3

Detailed description (please be as specific as possible):
When launching the GWT app in in development mode a large number of temporary file
are created in C:\Documents and Settings\{username}\Local Settings\Temp when the browser
connects. For my application these are...

08/09/2010  09:47             1,748 gwt-update-2.0.3.html
08/09/2010  09:44             9,824 gwt2187128894866021850byte-cache
08/09/2010  09:49            14,736 gwt5528173707954889534byte-cache
08/09/2010  09:49         6,461,630 gwt6027620159981911613byte-cache
08/09/2010  09:48                 0 gwt654613878423099672byte-cache
08/09/2010  09:49         1,717,017 gwt9064044682148305573byte-cache
08/09/2010  09:43    <DIR>          gwtc3149318699614677569.tmp
08/09/2010  09:49    <DIR>          gwtc8634648244986299905.tmp
08/09/2010  09:47    <DIR>          hsperfdata_pillingworth
08/09/2010  09:49               533 ImageResourceGenerator1145766482129054713.png   (repeated
x131)
08/09/2010  09:47    <DIR>          Jetty_0_0_0_0_5001_war____wrniql

These files are never cleaned up.

On my system I never cleaned the Temp folder which meant I had over 100000 files and
directories. This led to Eclipse taking over 20 minutes to start plus a general slow
down of other programs.

Shortest code snippet which demonstrates issue (please indicate where
actual result differs from expected result):
N/A

Workaround if you have one:
Manually clean the Temp folder

Links to relevant GWT Developer Forum posts:
http://stackoverflow.com/questions/3657054/eclipse-freezing-at-startup-before-loading-workspace/3665866#3665866

Reported by pillingworthz on 2010-09-08 08:59:14

dankurka commented 9 years ago
Thanks for reporting this.  I was wondering why my system had come to a grinding halt.
 I cleaned up the mess and now things work much better.

Reported by stevec5375 on 2010-11-01 18:47:33

dankurka commented 9 years ago
Does anybody know the reason why these files would need to be kept around? Eclipse's
start-up time went from 5 minutes to 5 seconds.

Reported by eric.s.landry on 2010-12-21 16:50:23

dankurka commented 9 years ago
I just dug through my computer trying to find a jetty log file and noticed there are
a ton of these ImageResourceGenerator#.png files in the temp directory.  Some of the
files were more than a year or 2 old.

Can't something be done about this??  Does GWT really need to regenerate these image
files if the original image file has not change?

Reported by patrick.tucker@macefusion.com on 2011-02-14 23:42:08

dankurka commented 9 years ago
We have worked around this issue by setting the "java.io.tmpdir" system property to
a location which is cleaned before and/or after each gwt build and dev-mode session.

Reported by steve@entreesystems.com on 2011-02-15 00:25:26

dankurka commented 9 years ago
On Linux this stuff ends up in /tmp.  Depending on your distro these may be cleaned
up automatically (e.g. http://www.cyberciti.biz/faq/debian-ubuntu-removes-files-at-boot-time/)

Reported by jsvaughan on 2011-02-24 11:39:39

dankurka commented 9 years ago
My directory has hundreds of thousands of files which I am now manually deleting. Surely,
this is not optimal. Please have the plugin clean up after itself.

Reported by jefftschwartz on 2011-02-24 12:57:10

dankurka commented 9 years ago
a workaround could be to add deletion of these files in the "clean" target of one's
project (test if windows platform, use username variable, ...). 
Not tested as I do not do any gwt those days.

Other idea, hook on the "shut down" (or close) of Eclipse and do the cleaning there,
from an OSGi bundle. Unsure this event exists :)

Reported by wadael on 2011-02-24 13:32:05

dankurka commented 9 years ago

Reported by bobv%google.com@gtempaccount.com on 2011-02-25 14:03:19

dankurka commented 9 years ago
Some other files that are getting stuck into this folder:
uiBinder_com.package.ui_ClassName_ClassNameUiBinderImpl_GenCss_style299724489983857619.css
ClassName_TypeSerializer8076668196336308.java

Reported by patrick.tucker@macefusion.com on 2011-04-06 18:25:07

dankurka commented 9 years ago
The project I'm working generates 15mb of junk in the temp folder for every new launch.
For the last couple of weeks I had been wondering why Eclipse was so slow at start
up, but cleaning the 16gb of GWT junk got start up time down from 10 minutes to 5 sec.

No one in my team was aware of this junk build up problem, and frankly this is something
GWT should handle without any special script or flags. Then should someone miss these
junk files, GWT can have a flag that prevents automatic deletion.

Reported by mathias.dam on 2011-04-11 11:48:11

dankurka commented 9 years ago
IMO, this is a serious flaw.  I don't seem to remember anywhere in the docs where we
are warned to look out for this.  I just deleted 40K files from my temp dir, wondering
why eclipse was taking 30+ minutes to start.

The plugin needs to clean up after itself.

Reported by thecatwhisperer on 2011-05-24 15:37:51

dankurka commented 9 years ago
I hacked together a groovy script to clean up my temp directory. I run it periodically
to do cleanup. Here is a copy/paste of it. 

def directory = "C:\\Documents and Settings\\jlarsen\\Local Settings\\Temp" //CHANGE
ME!!!!!!
deleteDirectory(directory)

public void deleteDirectory(String directory){
    File file = new File(directory)
    file.listFiles().each{
        println(it.getName())
        try{
            deleteDirectory(directory+"/"+it.getName())
        }catch(Exception e){
               //Do nothing. If the file is blocked, we don't care. 
        } 
        try{
           it.delete()
        }
           catch(Exception e){
               println(e)
           //do nothing, if we can't delete the file, we don't care. 
        }
    }
}

Reported by larsenje on 2011-07-12 18:42:42

dankurka commented 9 years ago
@Comment 12

If this script can be invoked right after close you eclipse workspace that would be
a elegant solution to all this . Does Eclipse provide such hooks ??

Reported by karthik.eleven on 2011-07-13 19:02:40

dankurka commented 9 years ago
While this issue is still ongoing, I just run this batch script every morning:

@ECHO OFF

IF "%1" == "/a" GOTO full

ECHO Default Clean
IF EXIST "%TEMP%\ImageResourceGenerator*" DEL "%TEMP%\ImageResourceGenerator*" /F /Q
IF EXIST "%TEMP%\uiBinder*" DEL "%TEMP%\uiBinder*" /F /Q
IF EXIST "%TEMP%\gwt*" DEL "%TEMP%\gwt*" /F /Q
FOR /D /R %TEMP% %%x IN (gwt*) DO RMDIR /S /Q "%%x"
GOTO end

:full
ECHO Full Clean
FOR /D /R %TEMP% %%x IN (*) DO RMDIR /S /Q "%%x"
DEL "%TEMP%\*" /F /Q
GOTO end

:end
ECHO.
ECHO Done.

Reported by jzhobes on 2011-07-26 13:50:03

dankurka commented 9 years ago
Does this issue is on track by the GWT dev team for further version?

We are developing a big solution based on GWT. and we cannot compile more than 5 permutations
because of the disk space needed by the compiler (on our integration server which has
300Go free).

This is a big problem as we need to compile for 5 language and all browsers (= 35 permutations.)

Reported by xav.alvaro on 2011-08-18 07:23:53

dankurka commented 9 years ago
My comment 7 describes a long term solution (OSGi, bundle, activator)

On dev. station a workaround could be to use a batch to start Eclipse then do the cleanup.

On an integration server (comment 15), doing the cleanup in the "clean" target before
each build is worth testing.

Reported by wadael on 2011-08-18 08:09:20

dankurka commented 9 years ago

Reported by rjrjr@google.com on 2011-10-05 00:45:52

dankurka commented 9 years ago
Shouldn't have shut this down, it's Rajeev's to triage.

Reported by rjrjr@google.com on 2011-10-05 16:35:05

dankurka commented 9 years ago
Thanks for sharing batch script

Reported by benjamin.ritchie on 2011-11-11 20:39:22

dankurka commented 9 years ago
I have had this same problem using Intellij instead of the eclipse plugin.

Reported by ben.stpierre2@printlogix.ca on 2012-02-03 22:58:03

dankurka commented 9 years ago
Is there any way we can configure where the temporary files are written? If so we could
point them at a RAM drive which not only means they get ditched when the machine shuts
down, but also it seems to me it would significantly improve compilation performance
because there seems to be masses of I/O to that temp folder during compilation.

Reported by bobgateaux@yahoo.com on 2012-02-10 21:09:27

dankurka commented 9 years ago
Bob,  That is mentioned by another user previously in this thread.  However, keep in
mind that these files add up quick, I've seen a few hundred megs of files generated
 over a days work.

If you're using windows, the work around that I setup was to build a windows Task to
have it delete the contents of the temp folder  (I don't really care if it causes issues,
so I can't speak to whether it does or not, but it shouldn't...)

I've this setup so that anytime my computer goes Idle, it attempts to delete the contents
of the folder.

Mostly this is all straight forward, but the easiest way I found to do it was to build
a task that runs when your system goes idle.  I added a Start Program action, with
the program set to;
     C:\Windows\system32\cmd.exe
and the "Add arguments (optional)" set to;
 /c "del /f/q/s C:\Users\***UserFolder***\AppData\Local\Temp"

This has worked pretty well so far, I've been using it for a couple days now.

Reported by james.lapenn on 2012-02-10 21:22:42

dankurka commented 9 years ago
Would be nice to put this one to rest for good..

Reported by rori@simplesmartads.com on 2012-05-19 18:06:19

dankurka commented 9 years ago
Any updates on this issue? When will plugin take care of this? Its pretty sad to see
this issue not addressed after more than a year.

My eclipse too was taking around 20+ minutes to load and didn't had any clue what was
going on, until I saw this link. 

Hope this will be addressed soon.

Reported by jaitthomas on 2012-05-31 00:20:31

dankurka commented 9 years ago
Serious issue as a large portion of our development team were seeing painful Eclipse
load times.
This needs fixing!

Reported by nik.colman%insidertech.co.uk@gtempaccount.com on 2012-06-15 15:33:41

dankurka commented 9 years ago
Hi all,

According to my comment #7, I've done an OSGi bundle/eclipse plugin to clean the gwt*
and uiBinder_* files in the TMP folder.

https://github.com/wadael/GWTCleaner

Despite tries & search, the plugin must be started by hand using OSGi console
Then, on next eclipse launch, it will be run again

hope it helps

Jerome (@wadael)

Reported by wadael on 2012-06-24 22:12:50

dankurka commented 9 years ago
Not bad Jerome. I wonder if your plug in could be... "pluged in" into official gwt-eclipse-plugin.

Reported by rocky303 on 2012-07-03 11:39:36

dankurka commented 9 years ago
Thanks Rocky

I believe the G guys can do better than me. 
My plugin only cleans the tmp files on start and stop of Eclipse so that restarting
Eclipse solves the slowness.

I "crossposted" this issue in the GPE tracker 
http://code.google.com/p/google-plugin-for-eclipse/issues/detail?id=74 

Jerome

Reported by wadael on 2012-07-03 11:58:34

dankurka commented 9 years ago
I agree with Bob in comment 21. I'd like to configure my own temp location to a RAM
drive to improve GWT dev speeds as there is a large amount of IO time spent reading/writing
to the temp files in hosted developer mode. Any updates to this?

Reported by austin.chaird on 2012-07-06 05:10:01

dankurka commented 9 years ago
Good proposition.

I guess that this is quite low on priority list, so only thing left is to realy on
our own resources to produce a patch which will be accepted by GWT team.

Reported by rocky303 on 2012-07-06 22:32:16

dankurka commented 9 years ago
God bless the internet.. +1 for that

Wish I could prioritise it, but life's too short :)

Reported by benjamin.ritchie on 2012-07-06 23:34:35

dankurka commented 9 years ago
Any chance the temp files can be put in a subfolder that is in the temp folder?  We
could then set a scheduled task that will delete the folder or its contents without
worrying about deleting something else.

Reported by tuckerpmt on 2012-07-07 01:21:06

dankurka commented 9 years ago
I found this quite annoying so I made this simple batch script (windows)

For max performance, F:/ is a RAM drive. Yours doesn't have to be, but it's nice. This
is a good one I use which is free up to 4GB http://memory.dataram.com/products-and-services/software/ramdisk/

Anyway

set TEMP=F:/Temp
set TMP=F:/Temp
eclipse
rd /s /q F:\Temp

This makes everything Eclipse GWT plugin use a different temp folder, then when you
shut eclipse, it runs the rd (remove directory.. like rm -rf in linux) command. That
way, every time you start Eclipse the temp folder should be clean. If you don't start/stop
eclipse very often then you could piggy back the logic from the run config of the dev
mode server. There's a batch file dev_appserver.cmd in the plugin directory. I havn't
tested doing it that way, but it should work if you insert the rd /s /q F:\Temp at
the end..

Honestly I just thought it was normal for Eclipse to take 10 mins to start. I was shocked
when I deleted my temp files and it started instantly :|

Reported by jason@pixeljet.net on 2012-07-13 03:19:49

dankurka commented 9 years ago
I am not using Eclipse but InteliJ and have the same problem. The temporary files apparently
are left by the GWT browser plugin.

Reported by asimov6 on 2012-10-23 19:53:21

dankurka commented 9 years ago
I just deleted 80 gigs worth of temp files...

Reported by tuckerpmt on 2013-01-07 22:14:13

dankurka commented 9 years ago
Issue 5965 has been merged into this issue.

Reported by t.broyer on 2013-03-19 10:57:41

dankurka commented 9 years ago
Hi everyone, I had exsctly the same problem so I created a linker that clears temp folder
every time I start Dev Mode. 

Use it like this:
<define-linker name="cleaner" class="com.promis.util.TempCleanerLinker" />
<add-linker name="cleaner" />

Reported by ramejan on 2013-03-19 11:00:04


dankurka commented 9 years ago
If the JVM is terminated normally, all temporary files should be deleted (see my comment
in issue 5436). It seems like the GPE forcibly terminates the JVM, which bypasses the
hooks; the easy solution would be to simply close the "remote UI" connection to the
DevMode process so it'll terminate by itself, and only possibly kill it if it didn't
terminate within a few seconds timeframe.

Reported by t.broyer on 2013-03-19 11:01:20

dankurka commented 9 years ago
I'm using Terminate and relaunch in the Debug view a lot. I think this would still keep
the files in place based on what you're saying. I have a suggestion, could the names
of the tmp file be saved somewhere so they would get cleaned the next time dev mode
starts?

Reported by ramejan on 2013-03-19 11:12:43

dankurka commented 9 years ago
moved to google plugin for eclipse issue tracker: https://code.google.com/p/google-plugin-for-eclipse/issues/detail?id=118

Reported by dankurka@google.com on 2013-04-16 21:49:43

dankurka commented 9 years ago
Why has this been migrated to an empty issue?
This is a problem which has not been resolved. Instead of wasting time 'migrating'
the issue so the comment thread is lost, how about fixing it?

Reported by nik.colman%insidertech.co.uk@gtempaccount.com on 2013-04-17 08:41:54

dankurka commented 9 years ago
The issue was on the GWT tracker, but this is not a GWT issue.

The comments are not lost since the new issue links back to this one.
If you care about this issue please report to the right issue tracker and make your
voice heard.

Reported by dankurka@google.com on 2013-04-17 08:54:11

dankurka commented 9 years ago
I would understand if the issue had been migrated a few days after being reported to
the wrong tracker, but it has been two and a half years since first being reported
with a continuous stream of comments since that time.

No indication of a fix on any of the connected issues. It's the equivalent of shuffling
papers.

Reported by nik.colman%insidertech.co.uk@gtempaccount.com on 2013-04-17 09:20:39

dankurka commented 9 years ago
I could be wrong, but I don't believe there was a GPE issue tracker when this bug was
first filed.

Reported by tuckerpmt on 2013-04-17 11:20:40

dankurka commented 9 years ago
More paper shuffling, this issue has now been merged to: https://code.google.com/p/google-plugin-for-eclipse/issues/detail?id=74

Reported by AndrewScully on 2013-04-26 10:14:44