[gradsusr] Memory considerations

Jennifer Adams jma at cola.iges.org
Thu Apr 8 08:23:02 EDT 2010


Hi, John --
The 'galloc' function was set up by Brian as a way to track memory  
overlays.  It is basically re-implementation of malloc that adds 8  
bytes to the end of each chunk of allocated memory and puts "AAAAAAAA"  
into those bytes. Then when that memory is freed (via the gree  
function, also part of galloc.c), then it checks to make sure those 8  
A's are still there. If not, then (if compiled in verbose mode) it  
issues a warning message that the memory has been overlaid. At any  
point when running GrADS interactively, you can use 'q mem' to show  
you the list of memory chunks that have been allocated with galloc.  
During the development of v2, the use of galloc and gree instead of  
malloc and free have been helpful for tracking memory usage and  
plugging leaks. Not every call to malloc in the GrADS source code has  
been replaced by galloc (especially in the graphics side). At some  
point, we will likely remove the calls to galloc and just use malloc  
instead, but for now it is still a useful debugging tool.

On Apr 7, 2010, at 6:32 PM, Huddleston, John wrote:

> Hello,
>
> Most users open up GrADS and do their work and exit wihtout a  
> serious hit to memory losses.
>
> However, my situation is unique in that I am running GrADS to create  
> thousands of satellite images; so, memory losses are steep.
You might try looking at the 'q mem' output after the 1st, 10th, 100th  
plot and it might reveal where the accumulating memory is getting  
allocated. Each instance of galloc has a name, which shows up in the  
'q mem' output. Also, you might try putting in a strategic 'reinit'  
now and then in your script -- this should release all memory (with a  
few small exceptions) and if you do a 'q mem' after a 'reinit' and it  
is still showing lots of allocated blocks then something is wrong.

>
> The losses are compounded within functions and eliminating those  
> losses with the free memory function causes GrADS to lose its mind.
Which functions are you calling? Recently a leak in lterp() was  
patched (after the release of 2.0.a8). If it is practical, can you  
give me a script that will demonstrate GrADS losing its mind? I'd like  
to see what that looks like, and also prevent it from happening.  
Perhaps drawing the same plot over and over again from a single file?

--Jennifer

>
> There are three calls in GrADS: galloc, malloc, and calloc. The  
> GrADS galloc call is the return call similar to malloc and calloc.
>
> The function galloc can be reinvented as a void call with all  
> arguments passed to it. New memory would be realloc.
>
> I would devote my time to reengineer GrADS with the designers if  
> they are willing.
>
> John
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

--
Jennifer M. Adams
IGES/COLA
4041 Powder Mill Road, Suite 302
Calverton, MD 20705
jma at cola.iges.org



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20100408/9d0fa126/attachment-0003.html 


More information about the gradsusr mailing list