views:

444

answers:

4

I have an application written in Python that's writing large amounts of data to the %TEMP% folder. Oddly, every once and awhile, it dies, returning IOError: [Errno 28] No space left on device. The drive has plenty of free space, %TEMP% is not its own partition, I'm an administrator, and the system has no quotas.

Does Windows artificially put some types of limits on the data in %TEMP%? If not, any ideas on what could be causing this issue?

EDIT: Following discussions below, I clarified the question to better explain what's going on.

+1  A: 

There shouldn't be such space limitation in Temp. If you wrote the app, I would recommend creating your files in ProgramData...

Nestor
It's just a utility application, and the data is in fact temporary, so even though you're right, I'm disinclined to move the data unless there's an actual problem storing it in `%TEMP%`.
Benjamin Pollack
+1  A: 

Using a FAT32 filesystem I can imagine this happening when:

  • Writing a lot of data to one file, and you reach the 4GB file size cap.
  • Or when you are creating a lot of small files and reaching the 2^16-2 files per directory cap.

Apart from this, I don't know of any limitations the system can impose on the temp folder, apart from the phyiscal partition actually being full.

Another limitation is as Mike Atlas has suggested the GetTempFileName() function which creates files of type tmpXXXX.tmp. Although you might not be using it directly, verify that the %TEMP% folder does not contain too many of them (2^16).

And maybe the obvious, have you tried emptying the %TEMP% folder before running the utility?

Yannick M.
My system's NTFS, and the biggest file it can write is roughly 2 GB.
Benjamin Pollack
I didn't vote you down; I just answered. You can check that in my voting history.
Benjamin Pollack
Can you provide the error code, because I am unaware of any system limitations apart from the inherent limitations of older filesystems.
Yannick M.
No it's fine, I assumed because it was roughly at the same time you answered that someone revoked his vote.
Yannick M.
I can't get the Win32 error, unfortunately; by the time it's in Python where I can grab it, Python's returning error 28 (see updated question), which on more reading does not actually necessarily mean what it sounds like it means. I updated the question accordingly. A limit of some type on `%TEMP%` still seems likely, but it might not be space per se.
Benjamin Pollack
A: 

There should be no trouble whatsoever with regard to your %TEMP% directory.

What is your disk quota set to for %TEMP%'s hosting volume? Depending in part on what the apps themselves are doing, one of them may be throwing an error due to the disk quota being reached, which is a pain if this quota is set unreasonably high. If the quota is very high, try lowering it, which you can do as Administrator.

cpkilekofp
+5  A: 

What is the exact error you encounter?

Are you creating too many temp files?

The GetTempFileName method will raise an IOException if it is used to create more than 65535 files without deleting previous temporary files.

The GetTempFileName method will raise an IOException if no unique temporary file name is available. To resolve this error, delete all unneeded temporary files.

One thing to note is that if you're indirectly using the Win32 API, and you're only using it to get temp file names, note that while (indirectly) calling it:

Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file.

If you're using that path but also changing the value returned, be aware you might actually be creating a 0byte file and an additional file on top of that (e.g. My_App_tmpXXXX.tmp and tmpXXXX.tmp).

As Nestor suggested below, consider deleting your temp files after you're done using them.

Mike Atlas
I would recommend looking at how many files you create
Earlz
I think we might have a winner. Need to do some more tests.
Benjamin Pollack
Interesting... I didnt know this!
Nestor
NOTE: A good programming pattern is to open temporary files with FileOptions.DeleteOnClose
Nestor