1

I had built my C++ code in Visual Studio for a smaller datasize to make it scalable. Now when I scaled it for huge data, it is showing me the error "C1060 compiler is out of heap space" and the code got terminated. I ran the same code on Dev C++, where it ran but I got the warning message that "out of memory allocating 1073745919 bytes".

I am using four 4D arrays and so many functions in my code. So, while searching for the solution, I got to know about the use of heap space instead of the stack, so I had moved the arrays to the heap by using 'new' operator in C++. Still, I am getting the same error message. Is there any coding command, by which I can run my code successfully? Or any other way also works.

Thanks in advance!

  • 5
    Your compiler ran out of memory, not the program you're writing. How large is your source file? – jyl Jul 04 '20 at 02:21
  • *Still, I am getting the same error message* -- Then maybe you need to consider building a 64-bit application instead of 32-bit. – PaulMcKenzie Jul 04 '20 at 02:38
  • 1
    I would recommend trying to scale down the program a little bit, first of all out of memory allocating 107 megabytes, does your array really need that much memory, that is an awful lot of memory to allocate for an array, what you are you trying to store?? Also some code would help, can we see the code?? – Yunfei Chen Jul 04 '20 at 02:43
  • This sounds like a good candidate to [Use 64 bit compiler in Visual Studio](https://stackoverflow.com/questions/46683300/use-64-bit-compiler-in-visual-studio). – dxiv Jul 04 '20 at 02:56
  • Well,if closing Visual Studio and do doing a full rebuild still give you that error, then your code is really complex or you have some infinite recursion (for example a loop in include files not properly escaped by an `#ifdef` or `#pragma once` or a complex recursive template or something weird. **If you are not able to figure out the problem, then comment out all code and bring them back in small portion until you find what is causing the problem,** – Phil1970 Jul 04 '20 at 03:25
  • This might help: https://stackoverflow.com/questions/23917089/visual-studio-express-fatal-error-c1060-the-compiler-is-out-of-heap-space – schteppe Jul 04 '20 at 11:37
  • Since you wrote that you are using arrays: are you allocating large arrays on the stack? If so, allocate them on the heap instead, perhaps using std::vector. – schteppe Jul 04 '20 at 11:38
  • The arrays are: double linkforward[N][N][C][S] = { 0 }; double linkbackward[N][N][C][S] = { 0 }; int KAllowforward[N][N][C][S]; int KAllowbackward[N][N][C][S] = { 0 }; where, N = 28, C = 7, S = 353. I had built a code so that the access to data in the array should be straightforward and I know that the memory allocated to this array is wasted in so many ways. I will try the suggested ways. Although the code is written on a windows system, I run the code on a server with ubuntu so I was looking for a code-based solution so that the same code will not have an issue on Windows as well as Ubuntu. – Shrinivas Petale Jul 05 '20 at 18:03

0 Answers0