Web lists-archives.com

Re: Memory problems running C programs using GCC in NetBeans/Cygwin on Windows

On 22/03/2017 00:06, Martin O'Shea wrote:

I am using a 64 bit GCC compiler in NetBeans to compile a series of C
programs which use the GMP multiple precision library to calculate numbers
with varying lengths of zeroes. The programs are called from a shell script
run from NetBeans or using Cygwin on Windows.

The Windows PC concerned has 8Gb memory and according to the following piece
of C code, the 64 bit version of Cygwin has 2Gb memory available:

    #include <stdio.h>
    #include <stdlib.h>

    int main(int argc, char** argv) {

        unsigned int bit = 0x40000000, sum = 0;
        char *x;

        while (bit > 4096) {
            x = malloc(bit);
            if (x)
                sum += bit;
            bit >>= 1;
        printf("%08x bytes (%.1fMb)\n", sum, sum / 1024.0 / 1024.0);

        return (EXIT_SUCCESS);

Given that the programs run without fault in Unix, I am assuming that there
must be an environmental issue concerning memory when running the programs
on Windows. Therefore, can anyone suggest if there is a way to increase
memory to the GCC compiler within NetBeans or for the project I have, or to
use `makefile` options to increase memory?

I am using version 5.4.0 of GCC as given below:

    $ gcc -v
    Using built-in specs.
    Target: x86_64-pc-cygwin

I also do not understand why the memory checker program returns 2Gb.

2Gb is the largest block available.
As you never use free you have reserved ~ 4Gb


Martin O'Shea.


Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple