[GRASS5] i.fft G_malloc: out of memory
glynn.clements at virgin.net
Sat Feb 23 13:53:57 EST 2002
Gualter Barbas Baptista wrote:
> I'm trying to do a Fast Fourier Transform (i.fft) to a landsat image and
> I always get a G_malloc: out of memory. I thought that this was because
> all the system memory was exhausted, but then I checked that I still had
> about 100 mb free swap memory.
How big is the image? i.fft is fairly wasteful of memory; it pads the
image to a power of 2, then requires 32 bytes (4 "double"s) per cell.
This could result in i.fft using nearly 8 times as much memory a is
The waste is primarily an artifact of the underlying fft() routine
having been replaced, without any changes to i.fft itself.
1. The old fft() function took its input in two separate arrays; one
for the real part, one for the imaginary part. The FFTW library, which
is used by the new version, requires a single array of complex numbers
(i.e. the real and imaginary components are interleaved).
Consequently, fft() creates a copy of the data.
2. The old fft() function required the array dimensions to be powers
of two. The new version doesn't, but i.fft still performs the padding.
Point 2 above should be fairly simple to fix. Point 1 is harder, as it
involves changing the interface, which requires changing all of the
programs which use it, which risks introducing bugs.
> Is this something I'm doing wrong or is it some bug from this function?
Not strictly a bug, just gross inefficiency. But it's quite possible
that i.fft really is exhausting memory (even if it's not exhausting
system memory, there may be a per-process limit which is being
> In Idrisi I have to pad the image to have lines and columns in a power
> of 2. Do I still have to do this in GRASS? If yes, how can I do a zero pad?
You don't have to pad to a power of two.
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-dev