Windows 中 TEMP 目录的限制?
我有一个用 Python 编写的应用程序,它将大量数据写入 %TEMP%
文件夹。奇怪的是,每隔一段时间,它就会死掉,返回IOError:[Errno 28]设备上没有剩余空间
。驱动器有充足的可用空间,%TEMP%
不是它自己的分区,我是管理员,系统没有配额。
Windows 是否人为地对 %TEMP%
中的数据设置了某些类型的限制?如果不是,有什么想法可能导致此问题吗?
编辑:经过下面的讨论,我澄清了这个问题,以更好地解释发生了什么。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您遇到的确切错误是什么?
您是否创建了太多临时文件?
需要注意的一件事是,如果您间接使用 Win32 API,并且仅使用它来获取临时文件名,请注意在(间接)调用它时:
如果您使用该路径但也更改返回的值,请注意您实际上可能正在创建一个 0 字节文件和一个附加文件(例如 My_App_tmpXXXX.tmp 和 tmpXXXX.tmp)。
正如 Nestor 下面建议的那样,请考虑在使用完临时文件后将其删除。
What is the exact error you encounter?
Are you creating too many temp 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:
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.
使用 FAT32 文件系统,我可以想象在以下情况下会发生这种情况:
除此之外,除了物理分区实际上已满之外,我不知道系统可以对临时文件夹施加任何限制。
另一个限制是 Mike Atlas 建议使用
GetTempFileName()
函数来创建tmpXXXX.tmp
类型的文件。尽管您可能不会直接使用它,但请验证%TEMP%
文件夹不包含太多此类文件 (2^16)。也许很明显,您是否尝试在运行该实用程序之前清空 %TEMP% 文件夹?
Using a FAT32 filesystem I can imagine this happening when:
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 typetmpXXXX.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?
Temp 中不应该有这样的空间限制。如果您编写了该应用程序,我建议您在 ProgramData 中创建文件...
There shouldn't be such space limitation in Temp. If you wrote the app, I would recommend creating your files in ProgramData...
您的 %TEMP% 目录应该没有任何问题。
您为 %TEMP% 的托管卷设置的磁盘配额是多少?部分取决于应用程序本身正在执行的操作,其中一个应用程序可能会由于达到磁盘配额而抛出错误,如果该配额设置得不合理高,这将是一种痛苦。如果配额非常高,请尝试降低配额,您可以以管理员身份执行此操作。
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.