Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Feb 2004 11:12:48 -0800
From:      "Howard G Bundock" <bundock@usgs.gov>
To:        freebsd-questions@FreeBSD.ORG
Subject:   FreeBSD 4.9 on i386, using Generic Mapping Tools, calloc
Message-ID:  <OF598C06A0.A035D7AD-ON88256E31.006796AD@wr.usgs.gov>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OF598C06A0.A035D7AD-ON88256E31.006796AD>