If the C++ malloc() function is failing after a certain number of iterations (totaling ~2 GB reserved memory) in a 32-bit program, it usually means you are running out of addressable memory. This can be confusing because you may have many gigabytes of RAM still free. The reason for this may be that you have not linked the 32-bit program with Large Address Aware flag set.
If you are using MinGW and MSYS, you can set the ld linker environment variable before using the “make” command:
An example in context of compiling the Go Engine Fuego:
env LDFLAGS="-Wl,--large-address-aware" CXXFLAGS="-O3 -ffast-math -DBOOST_THREAD_USE_LIB -static-libgcc -static-libstdc++" \ ../configure \ --with-boost-thread=boost_thread-mt \ --with-boost-program-options=boost_program_options-mt \ --with-boost-date-time=boost_date_time-mt \ --with-boost-filesystem=boost_filesystem-mt \ --with-boost-system=boost_system-mt \ --with-boost-unit-test-framework=boost_unit_test_framework-mt make