MSVC放弃带有“严重错误C1060:编译器空间不足”的模板重载代码。 [英] MSVC gives up on template heavy code with "fatal error C1060: compiler is out of heap space"

查看:163
本文介绍了MSVC放弃带有“严重错误C1060:编译器空间不足”的模板重载代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用MSVC(2010)编译一些相对较模板繁重的代码,但最终因致命错误C1060退出:编译器空间不足



整个事情只是一个翻译单元,相比之下,gcc可以很轻松地处理它(在VM内,资源明显减少)。



任何提示都在寻找什么?有任何相关的编译器选项吗?

解决方案

我遇到了类似的问题(也有大量模板),并且我已经在使用 / 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.

这篇关于MSVC放弃带有“严重错误C1060:编译器空间不足”的模板重载代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆