www.delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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 |
Message-ID: | <20030818215453.69513.qmail@web40808.mail.yahoo.com> |
Date: | Mon, 18 Aug 2003 14:54:53 -0700 (PDT) |
From: | Jim Holder <j_r_holder AT yahoo DOT com> |
Subject: | finding out how much memory is available with malloc, gcc, cygwin |
To: | cygwin AT cygwin DOT com |
MIME-Version: | 1.0 |
A program similar to the one listed below works for me on Linux but not under Cygwin. The idea is to find out how memory I can allocate on the machine. The Cygwin version keeps going (past 700MB), reporting that it has allocated more memory than the machine has. What am I doing wrong? Thanks. #include <stdlib.h> #include <stdio.h> int main(void) { char *p; int loop = 1; long allocated = 0L; const long PIECE = 1000L; const long TENMB = 10000000L; long nextTenMB = TENMB; while(loop) { p = (char*)malloc(PIECE); if(p == NULL) { printf("p == NULL\n"); loop = 0; } if(p == (char*)0) { printf("p == (char*)0\n"); loop = 0; } if(loop == 0) break; allocated += PIECE; if(allocated >= nextTenMB) { printf("%ld\n", allocated); nextTenMB += TENMB; } } printf("final: %ld\n", allocated); return 0; } Some environment particulars: - cygwin 1.3.19-1 - gcc 3.2-3 - windows 2000, version 5.0, service pack 4 __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |