|
Clearing memory of unnecessary items |
Top Previous Next |
|
In a GAMS run one can generate large temporary items which are not permanently required. For example one could have the sequence (memtest.gms)
Distance(I,j)=111; Cost(I,j)=a+b*distance(I,j);
and never use distance again. One can cause GAMS to release the item from memory consumed using clear or killIn particular using option clear=itemname as follows
option clear=distance;
in effects zeros all entries in the distance matrix. The kill option also completely removes the item
option kill=distance;
In either case, the memory is not recovered unless the file is saved and restarted or a solve is executed with solvelink=0 . Resetting a symbol to default values using "normal" assignment (i.e. x(i,j)=0;) is as fast as the execution time clear (or kill). The clear and kill are only more compact for for variables and equations where multiple statements would be needed to deal with each attribute (i.e. x.lo(i,j)=0;x.l(i,j)=0;x.up(i,j)=0 etc for scale, m and possibly others). Compile time clean and kill, in the form of '$clear symbol' and '$kill symbol' also (re)set the symbol to default values but only have an effect on save and restart.
Use of $kill allows the used to redeclare the symbol with a data statement as follows: set i /1,2,3/ $kill i set i /a,b,c/ |