delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:from:to:subject:date:message-id:mime-version | |
:content-type:content-transfer-encoding; q=dns; s=default; b=tIQ | |
TGv1rQmX9gSOI2sjG4sVsOhKDXko9e9IzkskW/zGAxrnNOBhF2YHi0piF4+NWJuh | |
8hNOB43ucFAiAnbejNbvm7802KmNpE3ZJK11JCUPzrMcNVz3WzL8hKV73FJZhc8d | |
T+0eqCUChnXoScwURDkukISn5TYzvgDlHFacOPms= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:from:to:subject:date:message-id:mime-version | |
:content-type:content-transfer-encoding; s=default; bh=UAWTOoo8k | |
hfe/G3V4PyE3x76s08=; b=IpycJ12mZSiVGE8povQ/NBnNcsXnfWjiZTTXxvStw | |
HLGitpS/s9Hp84V4gU/0z3P1Gcz4Lj4frDZHLRlRzBqub0yjPH3mfGVXBFofT9yX | |
x9voQbE+HkwFO7lLKgt+GlanqsH+Y8V7x0K5oAxJakSwQXnxgDuF3e52hifkvF3R | |
Cg= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=1.4 required=5.0 tests=AWL,BAYES_20,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=mountain, HContent-Language:en-gb, Hx-spam-relays-external:sk:smtp-ou, H*RU:sk:smtp-ou |
X-HELO: | mk-outbound-1.mail.uk.tiscali.com |
X-Spam: | 0 |
X-OAuthority: | v=2.2 cv=GK5KKaFK c=1 sm=1 tr=0 a=jRZRKqNdc/I3OI/Tdcjf4Q==:117 a=jRZRKqNdc/I3OI/Tdcjf4Q==:17 a=kj9zAlcOel0A:10 a=UtibbgUamv3jgFu10egA:9 a=FaR3Jv7GGxegwfQK:21 a=pwkarn4LVN2YJH1V:21 a=CjuIK1q_8ugA:10 |
From: | "Martin O'Shea" <m DOT oshea AT dsl DOT pipex DOT com> |
To: | <cygwin AT cygwin DOT com> |
Subject: | Memory problems running C programs using GCC in NetBeans/Cygwin on Windows |
Date: | Tue, 21 Mar 2017 23:06:18 -0000 |
Message-ID: | <001d01d2a297$c0761050$416230f0$@dsl.pipex.com> |
MIME-Version: | 1.0 |
X-CMAE-Envelope: | MS4wfIv8D7II9/kiyjvEBUgXG4OHGsONUbr2XTNLdTxvHSt2YaN42V9/Guq1co3HLUjxLl1I5TkOp/IAvPBC0hWHBI8z0VE18qUKp+jtF0jV6CVKhay0k6IF XONebpb0yU+2Zm4eCb9rRipLR+o0jLL5PLbENAGWtn+aEhqWg4Hosw4J |
X-IsSubscribed: | yes |
Hello 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. What I am finding at run-time is that several of the files report an error concerning memory usage: `Zinput for complex out of memory (zero) -2` Which is generated by the following code: void zinput(Zero out) { int i; ZEROS(out) = ZSIZE(out) = getinteger(); if ((out->zero = calloc(ZEROS(out), sizeof(Complex))) == NULL) { fatal("Zinput for complex out of memory (zero) %d", ZSIZE(out)); } if ((out->mult = calloc(ZEROS(out), sizeof(int))) == NULL) { fatal("Zinput for int out of memory (mult) %d", ZSIZE(out)); } for (i = 0; i < ZEROS(out); i++) { cinput(ZERO(out, i)); MULT(out, i) = iinput(); } } The `getInteger` function called above reads as follows: int getinteger(void) { char buff[MAX_BUFFER]; int i; int n; /* Strip leading comments and blank lines */ do { fgets(buff, sizeof (buff), stdin); i = strspn(buff, " "); } while (buff[i] == '#' || buff[i] == '\n'); if (sscanf(buff + i, "%d", &n) != 1) { fatal("Getinteger error (%s)", buff); } return n; } This code is buried deep within a mountain of undocumented C code originally written on Unix: it has not been modified at all. There is no documentation and the writer is not available. sizeof(Complex) returns 48. 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. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/lto-wrapper.exe Target: x86_64-pc-cygwin I also do not understand why the memory checker program returns 2Gb. Thanks 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |