Mail Archives: djgpp/1993/07/12/04:11:40
> Earlier today I wrote:
> > Does anyone know how to query the amount of available physical RAM
> > using gcc? Turbo C provides the coreleft() routine, but this is not
> > part of the standard C libraries. I seem to remember seeing some code
> > that made use of brk/sbrk to do this once upon a time...
> In response to a couple of replies to this message, let me be slightly
> more explicit. I am interested in finding out how much *electronic* heap
> space is available to my program at any given time. One solution might be
> to put malloc() or sbrk() in a loop, until all heap space is exhausted
> and a NULL pointer is returned. In addition to the obvious inefficiency,
> the virtual memory facility of DJGPP causes problems with this approach.
> Motivation for the above:
> I am writing an image processing program that makes use of 2-D fast
> Fourier transforms. 2-D FFT's are very memory-intensive, involving
> complex Fourier coefficients (i.e., 8 bytes per pixel). This memory
> gets allocated/deallocated dynamically with malloc()/free(). Although
> in-memory FFT's are not too bad, even the so-called "fast" transform is
> *extremely* slow if disk-swapping is required. Therefore it is important
> for me to know in advance whether or not I have enough physical memory
> (not virtual memory) available to do everything in RAM.
> Any suggestions? Thanks again - JW
> Dr. John M. Weiss, Associate Professor
> Department of Mathematics and Computer Science
> South Dakota School of Mines and Technology
> 501 East St. Joseph Street
> Rapid City, SD 57701-3995
> 605-394-6145 jweiss AT silver DOT sdsmt DOT edu
I have had the same pb for the same motivations, apparently there is
no (simple) way to determine how much free RAM, you have but my experience
with 2D FFT is that provide you have basically enough RAM in the machine to
fit your 2D array + 1~2 Mb you will swapp only once (or not) and the FFT is
going to be fast, we are currently dealing with array 64*32768. However,
you have to be carefuill when allocating a 2D array with DJGPP: the
allocation procedure work by chunk of power of 2 and if you allocate a
512 element line, it needs 4 extra bytes for the record and thus reserve
a 1024 chunk ! Thus allocating a 512*512 array line by line will in fact
freeze 2 times the expected size, with big array this turns out to be
dramatic. One way to overcome this pb is to allocate the big chunk
512*512 in one operation and then map an array of pointers to begining
of lines. If my explanantion is difficult to understand, I can repeat
in french or I can send an example if needed.
Good luck
Vincent AT physique DOT ens DOT fr
- Raw text -