6

I am trying to port a plugin written in C++ which actually does a lot of stuff, so there are lots of classes and ofcourse a lot of code as well!

But when I try to compile the plugin, the compiler throws the following error: fatal error C1060: compiler is out of heap space. If I check my task manager it shows that there is quite some space left on the memory. I even tried restarting.

I tried the usual answers on the internet on memory allocation limit and on stack overflow previously asked questions as well. None of them have seemed to work for me, hence I am here.

A few things that might be important. The plugin is extensively using the following libraries: FreeImage & protobuf-2.4.1 p.s. I compiled the source code using VS2012 compiler. Using a 64-bit machine

the error shows up in the second line of this code:

#if GOOGLE_PROTOBUF_VERSION < 2004000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please update
#error your headers.
#endif
#if 2004001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please
#error regenerate this file with a newer version of protoc.
#endif

I am lost, could anyone point me in the right direction? Thanks alot!

Community
  • 1
  • 1
deathNode
  • 134
  • 1
  • 1
  • 7
  • As a starter... What language are you using? – Basic Mar 31 '17 at 12:29
  • @Basic sorry, that would be C++ – deathNode Mar 31 '17 at 12:30
  • Do you use the compiler on a 32 or 64 bit system? – Darklighter Mar 31 '17 at 12:35
  • It's a 64 bit system – deathNode Mar 31 '17 at 12:37
  • Hmmm, how long does it take from build to error? – George Mar 31 '17 at 12:40
  • @George About 10-15 seconds – deathNode Mar 31 '17 at 12:43
  • Maybe you really are out of heap space, task manager usually shows the working set and not the commit charge. How much memory do you have? You could try increasing your page file size temporarily and see if it helps. – Darklighter Mar 31 '17 at 12:43
  • @Darklighter Memory: 45056MB RAM, Page file: 8426MB used, 81519MB available – deathNode Mar 31 '17 at 12:45
  • @ShehrozAlam I'm not really sure if this is related to your problem but it might help. Once we tried to compile C++ modules which we generated by script - they contained really lots of methods. In debug mode it was OK, but in release mode we couldn't complete the compile. (Unfortunately, I cannot remember the error anymore.) Solution was easy: we changed our code generator to split output with method implementations into multiple .cc files. It still needs quite long to compile the release but it does not die anymore. – Scheff's Cat Mar 31 '17 at 12:53
  • @Scheff okay, that's something new for me.. will read about it and give it a shot... thanks! – deathNode Mar 31 '17 at 12:58
  • 1
    @ShehrozAlam We use VS Express. The compiler itself is a 32 bit application regardless that it can build 32 bit as well as 64 bit. (Currently, we use the latter only.) About VS Pro (or whatever) I do not know. – Scheff's Cat Mar 31 '17 at 13:01
  • 2
    Since the compiler is a 32-bit application, it can run out of heap space even if there's plenty of physical RAM available. I suspect the generated protobuf files are simply too big. – molbdnilo Mar 31 '17 at 13:05
  • @Scheff that might be quite helpful in other situations... thanks – deathNode Mar 31 '17 at 13:11
  • @molbdnilo Aside of a heap error, I remember (some years ago) the compiler (VS2008 that time) muttered about something like object size exceeded (or something similar). Solution was the same: split .cc file into multiple files. – Scheff's Cat Mar 31 '17 at 13:11
  • 2
    @Scheff non Express editions have a native 64 bit compiler. I don’t know if this is used here but i’d guess so. The compiler may still have some random internal limits, so splitting the translation units into smaller pieces sounds like a good idea. – Darklighter Mar 31 '17 at 13:48

2 Answers2

2

I had the same problem with VC++ 2015 latest update (Update 3). Eventually I worked out that turning off pre-compiled headers avoids the problem.

This was a small project so the difference in build time was minor for us. If you have a large project and must use pre-compiled headers maybe you can try removing some of them.

Andrew W. Phillips
  • 3,254
  • 1
  • 21
  • 24
  • Thanks Andrew.. Since I could not find a highly plausible solution, I went the other way and turned a few things off. Basically found a work around. Should this problem ever occur again, I shall try this – deathNode May 09 '17 at 08:12
  • 2
    @deathNode It would be helpful if you described your working solution as a new answer so those that come across this question can see what new direction to explore. – KalenGi Oct 13 '17 at 15:41
1

So there were 2 work-arounds for that. Firstly, I could just simply comment out the provided header descriptions, and that seemed to work magically.

Second, since, the first option did not sound very appropriate, I just recompiled the whole library, and it worked. I am guessing, it was a compiler version mismatch or something. But that seems to work fine..

deathNode
  • 134
  • 1
  • 1
  • 7