godot
godot copied to clipboard
Godot writes a lot of temporary files to `C:\Users\<user>\AppData\Local\Godot` directory
Godot version
all versions (starting at 3.5.1)
System information
Windows 7 64 bits
Issue description
There are a lots (I have 3867 files for now since 22/11/2022) of files in directory C:\users<user>\AppData\Local\Godot like these:

There are used assets archives, thumbnails, and many other which are never deleted. My concerns is the directory is in a SSD with partitions defined as "tight" as possible,considering windows temporary space usage, but having temporary space which are growing like these without management can become a more and more serious issue with time.
Files are created for all version of Godot I use (stable 3.5.1 and almost all beta/RC since 4 beta9).
Steps to reproduce
Just use Godot editor, create project and add assets or use assets from the store.
Minimal reproduction project
N/A
Use Windows' disk cleaner functionality to remove temporary files. It's likely possible to make it run on a schedule if you really need the additional disk space, or even tell Windows to clear its contents on every reboot.
Godot could technically clean up old cache entries for you (by storing timestamp metadata for each file), but writing this metadata will add to the file size (since each file takes at least 4 KB on disk with partition alignment). Removing old files on startup will also make the editor slower to start, as Godot will need to loop over all files to check when they were last modified.
maybe removing files on startup would not be an issue since the number of files will not accumulate (assuming old temp files are deleted every startup), or cleanup can occur on schedule or on editor exit.
For reference, Unreal does the same thing, but on a much larger scale. I don't remember there being a feature for automatic clean up. It allows you to change the directory, though.
I've encountered this issue recently, surprised by over 400k files accumulated from different projects. @Calinou these are not "temporary files" and no, Windows cleaner won't touch them and i'd be angry if it could. This is cache which should be stored in project folder (in case of Godot 4.x that would be somewhere inside the .godot folder; there's no easy solution for 3.x yet).
There are at least three reasons to move them to the project folder:
- if anything breaks because of the corrupted cache/temporary files, it's easy to simply delete the
.godotfolder and let the engine recreate everything - removing project folder cleans all associated cache and temp data, leaving only logs, saves and shader cache in
%appdata%\Godot\app_userdata, which is expected - we can also change the hashing of cached thumbnails so they are not bound to global path (right now if you move the project to another directory, the thumbnails get invalidated, so you get twice as much cache files, which won't be automatically removed)
Godot 4 already moved some other project files to the .godot folder (which are still stored by 3.x outside the project folder, in %appdata%\Godot\projects).
This is cache which should be stored in project folder (in case of Godot 4.x that would be somewhere inside the .godot folder; there's no easy solution for 3.x yet).
The issue with storing cache in .godot/ is that it ends up in zipped MRPs, making them a lot larger than necessary. We already have this issue with the shader cache :slightly_smiling_face:
Windows cleaner won't touch them
This should be the case if you tick the Temporary files dialog in the Windows cleaner dialog. I don't remember if it's checked by default though. That said, the Windows cleaner doesn't run on a schedule by default, though you get prompted to run it if you run low on disk space.
This should be the case if you tick the Temporary files dialog in the Windows cleaner dialog.
No, because contrary to the documentation, they are not stored in %TEMP%\Godot\ but in %LocalAppData%\Godot and it makes huge difference. The latter one, as i said, is not cleaned and shouldn't be even touched by Windows cleaner.
https://github.com/godotengine/godot/blob/13a0d6e9b253654f5cc2a44f3d0b3cae10440443/platform/windows/os_windows.cpp#L1552
So first thing - it should be fixed to return the Temp path as in documentation so it can be cleaned by external tools if needed. Right now each opened project/sample/example/MRP leaves unmaintainable garbage.
Second thing - i disagree with the idea of storing project-specific caches and temporary files globally. You won't prevent sending .godot and .mono folders with MRPs. Some users store them on their repositories too, which is unnecessary. But it's the same case with Library folder in Unity, node_modules in Node.js projects, target in Rust projects etc.
Working in an enviroment where drive space is limited (for example MacBook Air and Windows laptop in my case) i don't get why project created and maintained on external drive bloats the space on other drive anyway (especially on system drive, which is default for storing user data on most systems). That's why Unity's Library or Rust's target folder contains everything - from compiler cache and downloaded dependencies to build artifacts.
Keeping the temp files with the project folder also has the advantage of playing nicely with existing anti-virus folder exception settings (which can provide a big performance boost while developing). As well as potentially keeping all the project I/O on a dev drive: https://learn.microsoft.com/en-us/windows/dev-drive/
As a workaround, is it safe to delete these files manually? Can confirm cleaner utility does not purge them and I did double check the temporary files setting.
Edit: btw CrashDumps in same folder fills up with about 120mb of cruft from Godot crashing when I open it (which is very common, but unrelated to this). That might be outside of Godot's control though.
@FishOfTheNorthStar Yes, it's safe