Hundreds of temporary files left behind

Hi,

I've only recently started with the Arduino, so only recently installed the IDE version 1.0. For an unrelated reason, I was looking in my computer folder c:\users<xxx>\AppData\Local\Temp\ and, in there, were over 760 folders related to Arduino, each containing a short text file.

It seems that every time the IDE is opened - whether a sketch is loaded or not - the IDE creates three temporary files but only deletes one of them when the IDE is closed.

Is this a bug or have I misconfigured something? I can't believe that the IDE is supposed to leave its temporay files behind.

Thanks,

John.

The Temp folder is supposed to hold temporary files. When do you want them deleted?

By definition, they are temporary.

Better check out your Internet browser cache folder, I bet there are a whole lot more files there.

I understand what you're saying but my Browser has a drop-down menu item which allows me to clear the cache/recent history and, in any event, there's a logical reason why it's desirable for a browser to cache its recent files.

It shouldn't be necessary for a user to navigate "manually" to an obscure folder that nobody ever visits. When an application creates temporary files and folders for its own use, personally, I would expect the application to do its own housekeeping. By definition, temporary should be temporary. To answer your question as to when do I want them deleted, that should be a configurable option in the IDE preferences: Immediately when the IDE closes, after xx Days, after 1MB etc.

John.

Hi
I checked on my system and there are indeed plenty of files in the temp folder for each run. It is unacceptable to leave so many temp files and even ore unacceptable so many folders.

The idea about temporary folder is that a can separate between core files (written in the installation folder or the my documents folder) and temporary files (written in the temp folder). As a user you can delete the files in the temp folder without risk of deleting crucial system files or personal data.
This is for instance handy when a program crashes and therefore was unable to delete the temporary files. It is however implied that a program writing in the temp folder cleans his files as much as possible. I think leaving 1 folder after each run is unacceptable.

The comparison with the browser is not correct because the browser will read the temporary files during later runs. Most browsers also have a "disk limit parameter" allowing to configure how much disk can be used. So it will never eat all your disk space. It also uses only one folder.

When to clean up? Wen you do not need it anymore. For instance when you close the sketch or when you close the last IDE window.

Best regards
Jantje

PS: having plenty of folders in the temp drive slows down the windows operating system. (I have no experiance with other operating systems but as far as I understand it is a hardware constraint and other OS's will suffer this as well)

Plenty of applications will create temporary files when they are launched and used. However, they also know to delete them when you exit the application. The Arduino IDE seems to be the only one that's dumb founded in that respect. 0 byte files get created and are never deleted. This does, after a while, clog up the temp folder, and ultimately will affect the OS itself.

By definition, temp files are exactly that, temporary. However, by Arduino "standards", they are permanent since they're never deleted. I call this bad coding practices. If you write an application that's creating temp files, you should also do your housekeeping and clean them up after the application is closed. Or at the very least, give the end user tools to manage the temp files, just like any browser does.

I've made it a habit to delete everything in my temp folder every week or two, thanks to using the IDE almost on a daily basis. It's ridiculous.

By the way, vwlowen, a quicker way to get to your temp folder next time is to click Start -> Run and type in '%temp%' without the quotes. Quick access.

I guess the question now is which temp files are associated with the arduino. There seem to be more than one type. Time to make a batch file to DEL jna*.tmp and similar.

Mine leaves behind folders named untitled123....4567.tmp in which is another folder, in which is sketch_ .ino file.

It also leaves behind folders named console123...4567.tmp in which are two files stderr.txt and stdout.txt - which may or may not actually contain text.

The third file is named jna1234....567.tmp (no folder) but that one is deleted when the IDE is closed.
.. And another folder named build1234....567.tmp which is also deleted when the IDE is closed.

I've had a quick go at writing a batch file but it needs to RemoveDirectories which are not empty (console*.tmp and untitled*.tmp) and I've long forgotten my DOS command line skills :frowning:

John.

On my Mac I found a quite a few temporary files lying around, but not all that many seemed to be related to the Arduino.

vwlowen:
Hi,

I've only recently started with the Arduino, so only recently installed the IDE version 1.0. For an unrelated reason, I was looking in my computer folder c:\users<xxx>\AppData\Local\Temp\ and, in there, were over 760 folders related to Arduino, each containing a short text file.

It seems that every time the IDE is opened - whether a sketch is loaded or not - the IDE creates three temporary files but only deletes one of them when the IDE is closed.

Is this a bug or have I misconfigured something? I can't believe that the IDE is supposed to leave its temporay files behind.

Thanks,

John.

Every time you compile, the ide copies your sources into a unique temporary directory, and compiles them there.
I don't know how often it creates the unique directory- if it is once per day, or once per running session of the ide.

zoomkat:
I guess the question now is which temp files are associated with the arduino. There seem to be more than one type. Time to make a batch file to DEL jna*.tmp and similar.

On Windows, as long as you don't have any applications open, you can delete all of them. Those that are still open in a process will cause an access error and you can just skip that file. When I empty my temp folder, only 2 files remain, and both of them are tied to windows processes.

The third file is named jna1234....567.tmp (no folder) but that one is deleted when the IDE is closed.

I had 400+ of these files at 300k each (and probably the same number of the others, console, build, and untitled). I have to kill the arduino IDE (javaw.exe) when it is non responsive using task manager, which may be why so many files are orphaned.

cappy2112:
Every time you compile, the ide copies your sources into a unique temporary directory, and compiles them there.
I don't know how often it creates the unique directory- if it is once per day, or once per running session of the ide.

It actually creates four unique directories and only deletes one of them.

As soon as you open the IDE, three folders are created: console<unique_number1>.tmp, untitled<unique_number2>.tmp and build<unique_number3>.tmp.

console<unique_number1>.tmp contains two files: stderr.txt and stdout.txt

untitled<unique_number2>.tmp contains a sub-folder: sketch_ which contains, at that point, contains a 0-byte file: sketch_.ino

Also created directly in the %Temp% folder is a file: jna<unique_number4>.tmp which, at this stage is 300KB in size.

It doesn't matter how many 'sibling' windows are opened from the the IDE, no more folders or files are created. If you load a sketch, nothing new happens until you compile it. Then a temporary <unique_number5>.s file is created that is deleted atomatically as soon as the compile ends.

When you close the last IDE window, the file: jna<unique_number4>.tmp and build<unique_number3>.tmp are both deleted. But console<unique_number1>.tmp, untitled<unique_number2>.tmp, sketch_ and sketch_.ino all remain.

So, basically, 3 unique folders and 3 unique files are permanently created every time the IDE is opened and closed.

John.

Sorry to follow my own post but, if anyone is interested, I've written a little batch file. I'll leave it on the desktop alongside the Arduino shortcut. [Use at your own risk!]

rem Arduino-cleanup.bat
rem ===================

rem Clean up temporary Arduino files & folders.
rem First change directory to location
rem of temporary folders...

cd c:\users\john\appdata\local\temp

for /d %%a in (console*.tmp) do rmdir /s /q %%a
for /d %%a in (untitled*.tmp) do rmdir /s /q %%a

John.

vwlowen:
Sorry to follow my own post but, if anyone is interested, I've written a little batch file. I'll leave it on the desktop alongside the Arduino shortcut. [Use at your own risk!]

John.

John,

Works great! Thank you.

-stef

I submitted a patch for this a couple months ago.

http://code.google.com/p/arduino/issues/detail?id=701

The console logs were intentionally left behind by Processing for help with debugging, but since we haven't tended to use them in Arduino, I applied Paul's patch to remove them. The jna files being left behind sounds like a result of Java crashing, and I'm not sure what we can do about them.

The jna file deletes on exit.

Closing the IDE "gracefully" leaves behind console and untitled folders.

I'm not sure I understand your comment about you having applied Paul's patch. As an Arduino newcomer, I just downloaded the latest (and only supported) version of the IDE.

John.

Not sure if anyone has mentioned it yet, but in windows, you can set the task scheduler to run disk cleanup which will delete all temporary files in user, local, and system temporary folders.

Set to run every night or once a week with defrag will keep on top of the files for you.

alternatively you can use the task scheduler to run a custom .bat to delete specifics

vwlowen:
I'm not sure I understand your comment about you having applied Paul's patch. As an Arduino newcomer, I just downloaded the latest (and only supported) version of the IDE.

That means it will (very likely) become part of the next release. Of course, if you download the latest code from github, and set up JDK and ant (and a ton of other stuff if you're stuck on Windows), you can build your own copy of Arduino from the very latest code. Usually that only makes sense if you're planning to actually hack on the code and submit patches. If you're just getting started with Arduino, it's best to stay with the official releases.

My patch only dealt with the console files. I've noticed the untitled ones piling up too, though not as fast. I'm sure someday those will bother me enough to develop a fix and submit another patch. But I may not get around to that for a very long time, if ever. So if they're bothering you now, the full source code and free tools to hack on it are just a few clicks and downloads away.....