From owner-freebsd-questions@FreeBSD.ORG Thu Feb 5 11:30:06 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 423F516A4CE for ; Thu, 5 Feb 2004 11:30:06 -0800 (PST) Received: from gscamnlm01.wr.usgs.gov (gscamnlm01.wr.usgs.gov [130.118.4.111]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0043643D78 for ; Thu, 5 Feb 2004 11:28:55 -0800 (PST) (envelope-from bundock@usgs.gov) To: freebsd-questions@FreeBSD.ORG X-Mailer: Lotus Notes Release 5.0.1b September 30, 1999 Message-ID: From: "Howard G Bundock" Date: Thu, 5 Feb 2004 11:12:48 -0800 X-MIMETrack: Serialize by Router on gscamnlm01/SERVER/USGS/DOI(Release 5.0.12HF345 | August 14, 2003) at 02/05/2004 11:28:55 AM, Serialize complete at 02/05/2004 11:28:55 AM MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: FreeBSD 4.9 on i386, using Generic Mapping Tools, calloc X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Feb 2004 19:30:06 -0000 I am running GMT on a FreeBSD i386 with 2GB physical memory and 6GB total swap space. Queries to the system show that I am truly running with that amount of memory (sysctl hw.physmem and top to see swap space.) My GMT script bombs when the grdproject program tries to allocate less than 100MB of memory (23049601 x 4bytes)! Even if I am forgetting about something in this calculation, it is 20 times less memory than what exists on the system, NOT INCLUDING SWAP! Is there a sysctl variable that I need to adjust, like a vm.??? or vfs.??? Is "calloc" the problem? I'm stumped. GMT code that is running when Fatal Error occurs - This is a routine, gmt_support.c, that is used by many of the GMT programs. void *GMT_memory (void *prev_addr, size_t nelem, size_t size, char *progname) { void *tmp; if (nelem == 0) return(VNULL); /* Take care of n = 0 */ if (prev_addr) { if ((tmp = realloc ((void *) prev_addr, (size_t)(nelem * size))) == VNULL) { fprintf (stderr, "GMT Fatal Error: %s could not reallocate more memory, n = %d\n", progname, nel em); exit (EXIT_FAILURE); } } else { if ((tmp = calloc ((size_t) nelem, (unsigned) size)) == VNULL) { fprintf (stderr, "GMT Fatal Error: %s could not allocate memory, n = %d, %d\n", progname, nelem, size); exit (EXIT_FAILURE); } } return (tmp); } Fatal Error - $cal_neva.script grdimage: Allocates memory and read data file grdimage: Allocates memory and read intensity file grdimage: project grdfiles grdimage: New grid size (nx,ny) 4801 by 4801 GMT Fatal Error: grdproject could not allocate memory, n = 23049601, 4 man page for calloc - The calloc() function allocates space for number objects, each size bytes in length. The result is identical to calling malloc() with an argument of ``number * size'', with the exception that the allocated memory is explicitly initialized to zero bytes. Howard Bundock U. S. Geological Survey Earthquake Hazards Team 345 Middlefield Road, MS977 Menlo Park, CA 94025 phone (650) 329-5621 FAX (650) 329-4732 bundock@usgs.gov