简体   繁体   English

Windows中TEMP目录的限制?

[英]Limitations of TEMP directory in Windows?

I have an application written in Python that's writing large amounts of data to the %TEMP% folder. 我有一个用Python编写的应用程序,它将大量数据写入%TEMP%文件夹。 Oddly, every once and awhile, it dies, returning IOError: [Errno 28] No space left on device . 奇怪的是,每过一次,它就会死掉,返回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. 驱动器有足够的可用空间, %TEMP%不是它自己的分区,我是管理员,系统没有配额。

Does Windows artificially put some types of limits on the data in %TEMP% ? Windows是否人为地对%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. 编辑 :在下面的讨论之后,我澄清了这个问题,以便更好地解释发生了什么。

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. 如果GetTempFileName方法用于创建超过65535个文件而不删除以前的临时文件,则会引发IOException。

The GetTempFileName method will raise an IOException if no unique temporary file name is available. 如果没有唯一的临时文件名可用,GetTempFileName方法将引发IOException。 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: 需要注意的一点是,如果您间接使用Win32 API,而您只是使用它来获取临时文件名,请注意在(间接)调用它时:

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 (eg My_App_tmpXXXX.tmp and tmpXXXX.tmp). 如果您正在使用该路径但也更改返回的值,请注意您实际上可能正在创建一个0byte文件和一个额外的文件(例如My_App_tmpXXXX.tmp和tmpXXXX.tmp)。

As Nestor suggested below, consider deleting your temp files after you're done using them. 正如Nestor在下面建议的那样,考虑在完成使用后删除临时文件。

Using a FAT32 filesystem I can imagine this happening when: 使用FAT32文件系统我可以想象这发生在以下情况:

  • Writing a lot of data to one file, and you reach the 4GB file size cap. 将大量数据写入一个文件,并达到4GB文件大小上限。
  • Or when you are creating a lot of small files and reaching the 2^16-2 files per directory cap. 或者,当您创建大量小文件并达到每个目录上限的2 ^ 16-2个文件时。

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. 除此之外,我不知道系统可以对temp文件夹施加任何限制,除了物理分区实际上已满。

Another limitation is as Mike Atlas has suggested the GetTempFileName() function which creates files of type tmpXXXX.tmp . 另一个限制是Mike Atlas建议使用GetTempFileName()函数创建类型为tmpXXXX.tmp文件。 Although you might not be using it directly, verify that the %TEMP% folder does not contain too many of them (2^16). 虽然您可能没有直接使用它,但请确认%TEMP%文件夹中不包含太多(2 ^ 16)。

And maybe the obvious, have you tried emptying the %TEMP% folder before running the utility? 也许显而易见,您是否尝试在运行该实用程序之前清空%TEMP%文件夹?

There shouldn't be such space limitation in Temp. Temp中不应有这样的空间限制。 If you wrote the app, I would recommend creating your files in ProgramData... 如果您编写了应用程序,我建议您在ProgramData中创建文件...

There should be no trouble whatsoever with regard to your %TEMP% directory. 关于%TEMP%目录应该没有任何问题。

What is your disk quota set to for %TEMP%'s hosting volume? 您为%TEMP%的托管卷设置的磁盘配额是多少? 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. 如果配额非常高,请尝试降低配额,您可以以管理员身份执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM