[GRASS5] Re: r.sunmask - memory leakage in GRASS lib

Eric G. Miller egm2 at jps.net
Tue Jun 12 00:51:37 EDT 2001


I did some debugging on r.sunmask and after running it via memprof it
seems the leaks are from repeated find file calls in the NULL data
handling code.  There are several leakages along the way.  Each is
rather small (the lengths of GISDBASE, LOCATION, MAPSET) but could
become substantial.  As the number of rows increases, so does the number
of memory leaks.  At program completion, I had a whopping 290K memory
leak with a very small file (100x100 float) (and short path to database).

We get G__open_null_read() calling G_find_file() directly, followed by
G_open_old (which calls G_find_file()).  G__open_null_read() is called
by G_get_null_value_row_nomask() which handles the caching of NULL data
rows (< NULL_ROWS_INMEM), etc...

G__find_file() returns a chunk created by a call to G_store(), so all
G_find_file() (which calls G__find_file()) results should be freed when
no longer needed: Hence,

    if (G_find_file("cell",name,mapset) != NULL) /* Memory leakage ... */

I think some of the related calls are leaking too, but I didn't follow
them all closely.

This memory leakage should be affecting a good portion of raster code,
so eliminating it isn't a bad idea ;)

-- 
Eric G. Miller <egm2 at jps.net>



More information about the grass-dev mailing list