這個問題以前已經問過很多次了,但沒有一個解決方案似乎對我有用。我創建了我的決策樹一個頭文件,它看起來像這樣編譯大的頭文件導致編譯器在第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