arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.35k stars 395 forks source link

Temporary files are not cleaned up #1795

Open per1234 opened 1 year ago

per1234 commented 1 year ago

Describe the problem

The Arduino IDE application creates some temporary folders:

These persist even after the user exits the IDE.

In the case of the first two on the list above, the folders accumulate over time, which may eventually cause a performance impact.

To reproduce

  1. Take note of the contents of your temporary folder.
    • Windows:
      C:\Users\<user name>\AppData\Local\Temp
    • Linux:
      /tmp
    • macOS
      $TMPDIR
  2. Start Arduino IDE.
  3. Select File > New from the Arduino IDE menus. This is treated as an unsaved sketch.
  4. Select File > Quit from the Arduino IDE menus.
  5. Examine the contents of your temporary folder.

🐛 An additional folder is present for each of the IDE windows you opened. 🐛 An additional folder is present for each of the unsaved sketches you opened. 🐛 An additional gdb-server-console-nnnn.log file is present for each of the IDE windows you opened. 🐛 The github-remote/, http-remote/, and theia_upload/ temporary folders Arduino IDE creates are still present

Expected behavior

Temporary files are cleaned up on exit.

Arduino IDE version

76f9f63

Operating system

Operating system version

Additional context

This is similar to https://github.com/arduino/arduino-ide/issues/1779. However, the two are distinct in that https://github.com/arduino/arduino-ide/issues/1779 allows for easier management of the temporary files during runtime (e.g., configuring antivirus software exclusions) and manual cleanup of files leftover when the application is not able to perform an automatic cleanup (e.g., power outage, crash).


Some operating systems may eventually do a clean-up on the temporary folder, but this is not guaranteed. It is better for the application to take care of clean up of any temporary files once they are no longer needed.


Additional temporary files are generated by tools used by Arduino IDE (e.g., Arduino CLI, arduino-fwuploader, Arduino Language Server, clangd). Cleanup of those file should be the responsibility of the individual tool, not Arduino IDE, so cleanup of those files is out of scope for this issue.

They are tracked in the repositories of those projects:

Additional reports

Related

Issue checklist

gashtaan commented 11 months ago

The ticket is year old and there is still massive temporary folder pollution in recent Arduino IDE.

I'm using the IDE very sporadically these days and nevertheless I just had to manually clean hundred files and directories like these:

arduino-ide2-XXX
arduino-language-serverXXX
gdb-server-console-XXX.log
system-includes-XXX.clangd
dlarue commented 11 months ago

I run with 2 scripts for Arduino 2.x IDE, one named arduino2 which does not cleanup afterwards and is used when I'm building a few things or running debugging sessions so I might restart the IDE. Then I have arduino22 which is one which calls a tmp-cleanup script after the ide finishes and that does all the /tmp file and directory deletions. Or, after I'm finished with the debugging/etc using arduino2 script I just run the tmp-cleanup script directly.

Kinda a PIA but eased by just needing to run the script isn't too painful.

ednieuw commented 5 months ago

The Temp\arduino folder should be cleaned regularly. It is now 600 Mb large and full with 0 bytes folders.