Windows 中 TEMP 目录的限制?

发布于 2024-08-09 16:36:36 字数 322 浏览 6 评论 0原文

我有一个用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

源来凯始玺欢你 2024-08-16 16:36:36

您遇到的确切错误是什么?

您是否创建了太多临时文件

GetTempFileName 方法将引发
IOException(如果用于)
创建超过 65535 个文件,无需
删除以前的临时文件。

GetTempFileName 方法将引发
如果没有唯一的临时值,则抛出 IOException
文件名可用。解决
这个错误,删除所有不需要的
临时文件。

需要注意的一件事是,如果您间接使用 Win32 API,并且仅使用它来获取临时文件名,请注意在(间接)调用它时:

创建一个唯一命名的零字节
磁盘上的临时文件
并返回
该文件的完整路径。

如果您使用该路径但也更改返回的值,请注意您实际上可能正在创建一个 0 字节文件和一个附加文件(例如 My_App_tmpXXXX.tmp 和 tmpXXXX.tmp)。

正如 Nestor 下面建议的那样,请考虑在使用完临时文件后将其删除。

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.

独孤求败 2024-08-16 16:36:36

使用 FAT32 文件系统,我可以想象在以下情况下会发生这种情况:

  • 将大量数据写入一个文件,并且达到 4GB 文件大小上限。
  • 或者当您创建大量小文件并达到每个目录上限 2^16-2 个文件时。

除此之外,除了物理分区实际上已满之外,我不知道系统可以对临时文件夹施加任何限制。

另一个限制是 Mike Atlas 建议使用 GetTempFileName() 函数来创建 tmpXXXX.tmp 类型的文件。尽管您可能不会直接使用它,但请验证 %TEMP% 文件夹不包含太多此类文件 (2^16)。

也许很明显,您是否尝试在运行该实用程序之前清空 %TEMP% 文件夹?

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?

北座城市 2024-08-16 16:36:36

Temp 中不应该有这样的空间限制。如果您编写了该应用程序,我建议您在 ProgramData 中创建文件...

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

楠木可依 2024-08-16 16:36:36

您的 %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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文