Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 Subject: finding out how much memory is available with malloc, gcc, cygwin To: cygwin AT cygwin DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 #include 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/