9.3 MEMORY USE
Ferret indicates memory problems by issuing the error message "request exceeds memory setting" (or, in older versions of Ferret, "insufficient memory"). If memory is a problem running Ferret the following suggestions may help:
1) Use the command SET MEMORY/SIZE=nnn to increase the memory cache region available to Ferret. The number of words listed in the memory is the size of the request which failed; the total requirement for memory may be larger than shown. nnn is expressed in MWords. For operations that just load the data, nnn will need to be approximately the size in words that is quoted in the message, divided by 1.e6. For many operations, such as graphics operations or transforms, the calculations need more memory, and so perhaps twice that size will be needed. To increase memory every time you start Ferret, add a SET MEMORY/SIZE= command to your .ferret startup file
2) Use the command SET MODE DESPERATE to determine the threshold size of memory objects at which Ferret will break a large calculation into fragments. A smaller argument value will induce stricter memory management but at a penalty in performance.
3) Use CANCEL MEMORY whenever you are sure that the data referenced thus far by Ferret will not be referenced again. This is particularly appropriate to batch procedures that use Ferret. This eliminates any memory fragmentation that may be left by previous commands.
4) Use CANCEL MODE SEGMENTS to minimize the memory usage by graphics (on a few X-window systems this may prevent windows from being restored after they are obscured).
5) When using DEFINE VARIABLE (alias LET) avoid embedding upper and lower axis bounds within the variable definition. Ferret cannot split up large calculations along axes when the limits are fixed in the definition. For example,
yes? LET V2=TEMP/10
yes? PLOT/K=1:10 V2
is preferable to
yes? LET V2=TEMP[K=1:10]/10
yes? PLOT V2
6) Try to group together calculations that are on smaller dimensioned objects. For example, the expression VAR[i=1:100, j=1:100]*2*PI will make less efficient use of cpu and memory than the expression VAR[i=1:100, j=1:100]*(2*PI). The former multiplies each of the 10000 points of VAR by 2 and then performs a second multiplication of the 10000 result points by PI. The latter computes the scalar 2*PI and uses it only once in multiplying the 10000 points of VAR.
7) After complex plots using viewports, use CANCEL VIEWPORTS to clear graphics memory.
8) If one has SET MODE STUPID:weak_cache, then make sure that the region is fully defined (i.e., check SHOW REGION and check the region qualifiers of your command). When the region along some axis is not specified Ferret defaults to the full span of the data along that axis and is unable to optimize memory usage.