更新时间:2023-11-02 15:38:10
我遇到了类似的问题(也有大量模板),并且我已经在使用 / Zm1000
来编译我的代码(最初有效)。但是,在清理代码,将长函数划分为较小的函数,将内容放入命名空间等之后,编译器将吐出错误消息:
严重错误C1060:编译器空间不足。
启动后立即出现,没有任何延迟(实际上似乎没有编译任何东西)。起初,我很困惑,因为我有32 GB的交换空间,而当时只使用了6.1 GB。我也在运行x64操作系统,因此每个人都应该有足够的内存和交换空间。
我指的是 MSDN ,发现我实际上需要降低至 / Zm800
,现在效果很好。我的理解是,占用预编译标头缓冲区的所有堆空间实际上会锁定内存空间。因此使用 / Zm2000
将使32位编译器无法为其他内容动态分配内存(某种程度上它也需要,从而使 / Zm
选项完全荒谬-请谨慎使用。)
我正在使用MSVC 6.0,但希望对2010年有所帮助。
p>I am trying to compile some relatively template heavy code with MSVC (2010), and it eventually quits with fatal error C1060: compiler is out of heap space
.
The whole thing is just one translation unit, and, in comparsion, gcc handles it quite easily (inside a VM, with significantly fewer resources).
Any hints what to look for? Are there any relevant compiler options?
I had a similar issue (also template-heavy), and I was already using /Zm1000
to compile my code (which worked initially). However, after cleaning-up the code, dividing long functions to smaller ones, putting stuff to namespaces / etc., the compiler would spit out the error message:
fatal error C1060: compiler is out of heap space.
right after starting, without any delay (not actually seeming to compile anything). At first, I was confused, as I have 32 GB of swap space and only about 6.1 GB was used at the time. I'm also running x64 OS, so there should be a plenty of memory and swap for everyone.
I referred to MSDN and found out that I actually needed to lower to /Zm800
and now it works great. My understanding is that taking up all heap space for the precompiled header buffer actually locks out the memory space; so using /Zm2000
would leave a 32-bit compiler without means to dynamically allocate memory for other stuff (which it somehow also needs, making the /Zm
option completely ridiculous - use with caution).
I'm using MSVC 6.0, but I hope this helps in 2010 as well.