RainCode is a rather memory-hungry process. The
MaxMem configuration variable
can be used to
specify a larger amount of memory.
Typically, RainCode might require over 50 megabytes of RAM to analyze a source file of over 60000 lines. It is true however that the size and complexity of the data structures created by your scripts can have a significant influence on your memory consumption.
You can check whether the scripts are responsible for the memory problem by reading the source file without executing a script at all. If the parsing fails, it means that the source file by itself requires more memory to be parsed. If it succeeds, check the script for the creation of large and perhaps useless data structures.
For instance, it is tempting to bypass the usage of the filter expression by using an explicit loop, and to write:
FilterList := {};
FOR IN BigList DO
IF SomeProperty(X) THEN
FilterList :=FilterList & {X};
END;
END;
rather than:
FilterList := BigList | SomeProperty(X);
but if the filter expression yields 1000 elements out of BigList, the explicit loop above will create 1000 intermediate lists of length 1, 2, 3, etc..., while the filter expression will just create the filtered list without creating any useless intermediate data structure.