Windows 中 TEMP 目录的限制?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1683831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Limitations of TEMP directory in Windows?
提问by Benjamin Pollack
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 plentyof free space, %TEMP%
is not its own partition, I'm an administrator, and the system has no quotas.
我有一个用 Python 编写的应用程序,它将大量数据写入%TEMP%
文件夹。奇怪的是,每隔一段时间,它就会死去,然后返回IOError: [Errno 28] No space left on device
。驱动器有足够的可用空间,%TEMP%
不是它自己的分区,我是管理员,系统没有配额。
Does Windows artificially put some types of limits on the data in %TEMP%
? If not, any ideas on what could be causing this issue?
Windows 是否人为地对 中的数据设置了某些类型的限制%TEMP%
?如果没有,关于可能导致此问题的任何想法?
EDIT: Following discussions below, I clarified the question to better explain what's going on.
编辑:在下面的讨论之后,我澄清了这个问题以更好地解释发生了什么。
回答by Mike Atlas
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 65535files 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.
如果 GetTempFileName 方法用于创建超过65535 个文件而不删除以前的临时文件,则会引发 IOException 。
如果没有唯一的临时文件名可用,GetTempFileName 方法将引发 IOException。要解决此错误,请删除所有不需要的临时文件。
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,并且仅使用它来获取临时文件名,请注意(间接)调用它:
Createsa uniquely named, zero-byte temporary file on diskand 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).
如果您正在使用该路径但也更改了返回的值,请注意您实际上可能正在创建一个 0 字节文件和一个附加文件(例如 My_App_tmpXXXX.tmp 和 tmpXXXX.tmp)。
As Nestor suggested below, consider deleting your temp files after you're done using them.
正如下面 Nestor 建议的那样,请考虑在使用完临时文件后删除它们。
回答by Yannick Motton
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.
- Or when you are creating a lot of small files and reaching the 2^16-2 files per directory cap.
- 将大量数据写入一个文件,您就达到了 4GB 的文件大小上限。
- 或者当您创建大量小文件并达到每个目录上限 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.
除此之外,除了物理分区实际上已满之外,我不知道系统可以对临时文件夹施加任何限制。
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).
另一个限制是 Mike Atlas 建议使用GetTempFileName()
创建tmpXXXX.tmp
. 尽管您可能不会直接使用它,但请确认该%TEMP%
文件夹中没有包含太多 (2^16)。
And maybe the obvious, have you tried emptying the %TEMP% folder before running the utility?
也许显而易见的是,您是否尝试在运行该实用程序之前清空 %TEMP% 文件夹?
回答by Nestor
There shouldn't be such space limitation in Temp. If you wrote the app, I would recommend creating your files in ProgramData...
Temp 中不应该有这样的空间限制。如果您编写了该应用程序,我建议您在 ProgramData 中创建您的文件...
回答by cpkilekofp
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? 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.
您为 %TEMP% 的托管卷设置的磁盘配额是多少?部分取决于应用程序本身正在做什么,其中一个可能会由于达到磁盘配额而引发错误,如果此配额设置得不合理,这会很痛苦。如果配额非常高,请尝试降低它,您可以以管理员身份执行此操作。