这个问题以前已经问过很多次了,但没有一个解决方案似乎对我有用。我创建了我的决策树一个头文件,它看起来像这样编译大的头文件导致编译器在第2遍错误中出现堆空间错误
class PredictClass0 : public CompiledTree
{
public:
PredictClass0(const std::string& modelDirectory) :
CompiledTree(20, 17, modelDirectory)
{
}
std::size_t predict_probabilities(const gst::ShottonFeatureAlgorithm &algorithm, const GstFrame* const frame, const std::size_t pixel,const std::vector<ParamValues>& offsetThresholdPair)
{
if (algorithm.computeFeature(frame,pixel,offsetThresholdPair[0].offsetPairs) < offsetThresholdPair[0].threshold)
{
if (algorithm.computeFeature(frame,pixel,offsetThresholdPair[1].offsetPairs) < offsetThresholdPair[1].threshold)
{
if (algorithm.computeFeature(frame,pixel,offsetThresholdPair[2].offsetPairs) < offsetThresholdPair[2].threshold)
{
if (algorithm.computeFeature(frame,pixel,offsetThresholdPair[3].offsetPairs) < offsetThresholdPair[3].threshold)
//and the list goes on....
头文件的大小30MB的,我有其中3,它需要6个小时编译(最终误差)。我尽可能地尽量减少符号和表达的数量。到目前为止,我已经尝试了这些解决方案:
设置编译器标志/ MP(多处理器编译)
编译器内存分配M/Z
进行最低限度的构建/ GM
- 将堆保留和提交大小设置为10000000
在Win 10机器上尝试了所有这些,这些机器上都有32GB RAM和64GB内存。我想知道是否有一个整洁的方式来处理大文件的编译?
你可以预先编译头文件吗? – wallyk
是的,但即使我使用PCH,问题依然存在,需要进行大量的计算。 – MarKS