jeudi 10 août 2017

Compiling big header files leads to Compiler is out of heap space in pass 2 error

This question has been asked lot of times before but none of the solutions seem to work for me. I created a header file for my decision tree which looks like this

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....

The header file has a size of 30MB and i have 3 of them and it takes 6 hours to compile(error in the end). I have tried to minimize the amount of symbols and expressions as much as i can. So far i have tried these solutions:

  • MSDN Solution

  • Setting compiler flag /MP (Multiprocessor compilation)

  • Compiler memory allocation /Zm

  • Enable minimal build /Gm

  • Setting Heap reserve and commit size to 10000000

Tried all these on a Win 10 machine with 32GB RAM and around 64GB memory left on my SSD. I would like to know if there is a neat way to handle compiling of huge files?

Aucun commentaire:

Enregistrer un commentaire