Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
When is the tmp directory cleared?
-
Running
os.listdir(tempfile.gettempdir())
shows tons of files, including (I think) every image I've everImage.show()
ed. Is this ever cleared? They are, after all, tempfiles.Turns out, I have
PIL.Image.show()
ed many, many images.
I'm pretty sure these are PIL's tempfiles just because I've seen file names for them on my Mac before when usingImage.show()
in Preview. -
The OS should periodically clean them up (e.g. when you reboot), but honestly, this has been on my todo list for a long time... The console should really clean this up by itself.
-
@omz Cool, hope to see it soon.
>>> len(os.listdir(tempfile.gettempdir())) 1006
Most are, indeed, PIL images.
Looking at the list, there are only 5 that are not PIL images. 1000 images inside Pythonista probably taking up quite a bit of space. But because it's not in the main bundle (I don't think), it might not show in "Manage Storage" as being linked to Pythonista. (Pythonista 3 and Pythonista 2 show up as separate apps, but I think they share atmp
directory. -
@Webmaster4o it's what was in my mind that held me back using tmp as a better working space in
cloud.Import
. I once had Pythonista crash that orphaned, it seemed, a large tmp file. -
@guerito And a full reboot of your device didn't clean it up? I would assume that iOS devices do a
fsck
when you boot them and clean up any orphaned files and such. If they don't that would be quite problematic, since you can't just boot them in recovery mode like a Mac. -
I just removed every file in
tmp
(Not directories, I didn't have permission to deleteMediaCache
). I think my device storage went up about half a gigabyte.OS X obviously does a better job at removal. If I
show()
an image, then in Preview I select all, copy, and create a new from clipboard, I get a mangled and corrupted mess of pixels@dgelessus I didn't try reboot. I almost never reboot my iPad. Every time it shuts off, it's either a respring or a software update. Neither of those seems to have cleared
tmp
. Maybe a good full reboot would have. Too late now :) -
Checked the
tmp
directories for both Pythonista 2 and 3 before and after rebooting, and they were both empty, except for a leftovermaster.zip
from installing stash. @ywangdThen again, my iPad reboots quite often on when installing too many app updates at once. And I recently (a few weeks ago) installed the iOS 9.2.1 update, perhaps then it cleans out the temporary folders.
(There's also
/var/tmp
which is used byos.tmpnam
, but mortal users don't have read permission there and cannot see what files are there.) -
@dgelessus Thanks I'll make sure the setup files are deleted at the end.