C1060 while compiling large hard-coded char array with VS2005

  • Thread starter Thread starter Lubdha Khandelwal
  • Start date Start date
L

Lubdha Khandelwal

I'm using VS2005 to compile a file that only contains a single large
(100MB) hard-coded char array.

It looks like:

unsigned char test[] = {
0x50,0x4b,0x3,0x4,0x14,0x0,0x0,0x0,0x8,0x0,0x5c,0x6c,
...................
.........................
};

As mentioned, the length of test[] is ~100MB and the size of the
test.c file is ~500 MB with all the punctuation etc. While compiling,
cl.exe exits with the error:

test.c(622984) : fatal error C1060: compiler is out of heap space

I am running this with 2G RAM, and I can see the cl.exe process
consuming >1.5G of memory before it gives up.

Any ideas why cl is using 3 times as much memory?
Is there any "hard" limit on the size of the array, or the file?

Thanks,
Lubdha
 
Lubdha said:
I'm using VS2005 to compile a file that only contains a single large
(100MB) hard-coded char array.

It looks like:

unsigned char test[] = {
0x50,0x4b,0x3,0x4,0x14,0x0,0x0,0x0,0x8,0x0,0x5c,0x6c,
..................
........................
};

As mentioned, the length of test[] is ~100MB and the size of the
test.c file is ~500 MB with all the punctuation etc. While compiling,
cl.exe exits with the error:

test.c(622984) : fatal error C1060: compiler is out of heap space

I am running this with 2G RAM, and I can see the cl.exe process
consuming >1.5G of memory before it gives up.

Any ideas why cl is using 3 times as much memory?

Compilers are complex things - you can't expect compilation of a 500Mb
source file to use 500Mb of memory.
Is there any "hard" limit on the size of the array, or the file?

I believe that there is, and that you're orders of magnitude past it. If
you want to include a binary image in a build, there are much better ways to
do it than emitting a 100Mb initialized array as C code. For example, embed
the binary file as a resource.

-cd
 
I believe that there is, and that you're orders of magnitude past it. If
you want to include a binary image in a build, there are much better ways to
do it than emitting a 100Mb initialized array as C code. For example, embed
the binary file as a resource.

Thanks for your response. I had started the way of embedding it as a
binary resource. However I need a cross-platform solution that works
across Linux, Mac, Windows etc so I was hoping to generate a custom
solution. Proably not.

Lubdha
 
Back
Top