I try to build ChaiScript on a remote virtual machine with only 512MB RAM. When compiling with gcc 6.2.0 the machine runs out of memory Are there any tricks to reduce the memory footprint?
Fyi: I found that Clang++ 3.8 has the lowest memory consumption but still too much. This makes ChaisScript not compilable on small device
Unfortunately the template work I’m doing does require a lot of RAM with modern compilers. Interestingly, you might have better results with MSVC, but I’m guessing you’re not using Windows.
Yeah, windows is not an option. I ordered a new dev machine. 4GB RAM should be enough hopefully.
I am having exactly the same problem here. I have a machine. I need to compile in a machine with 2 GB of RAM and the memory is exhausted when compiling the bindings. I will try some luck splitting but I really think that this is a problem that should be dealt with at some point.
If you use G++ you might want to take a look at the options regarding its garbage collector:
ggc-min-expand GCC uses a garbage collector to manage its own memory allocation. This parameter specifies the minimum percentage by which the garbage collector's heap should be allowed to expand between collections. Tuning this may improve compilation speed; it has no effect on code generation. The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when RAM >= 1GB. If getrlimit is available, the notion of “RAM” is the smallest of actual RAM and RLIMIT_DATA or RLIMIT_AS. If GCC is not able to calculate RAM on a particular platform, the lower bound of 30% is used. Setting this parameter and ggc-min-heapsize to zero causes a full collection to occur at every opportunity. This is extremely slow, but can be useful for debugging. ggc-min-heapsize Minimum size of the garbage collector's heap before it begins bothering to collect garbage. The first collection occurs after the heap expands by ggc-min-expand% beyond ggc-min-heapsize. Again, tuning this may improve compilation speed, and has no effect on code generation. The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but with a lower bound of 4096 (four megabytes) and an upper bound of 131072 (128 megabytes). If GCC is not able to calculate RAM on a particular platform, the lower bound is used. Setting this parameter very large effectively disables garbage collection. Setting this parameter and ggc-min-expand to zero causes a full collection to occur at every opportunity.