CS5403
error Stopped: the script used more memory than allowed.
#What it means
The script needed more memory than a script is allowed. This is checked while the script runs, and for very large scripts also when it is compiled.
#Typical cause
statecollections that keep growing, such as an array of large matrices that gets a new one on every bar.- Very many stateful calls (for example
ta.*inside functions called from many places).
#How to fix it
Keep stored data small: trim old elements, reuse one collection instead of creating new ones, and store numbers rather than whole objects where you can. See Performance.
#Example
//@chartscript 1
indicator("Snapshots")
state grids = array.new<matrix<float>>()
grids.push(matrix.new<float>(300, 300, 0.0))
plot(grids.size())Fixed
//@chartscript 1
indicator("Snapshots")
state grids = array.new<matrix<float>>()
grids.push(matrix.new<float>(30, 30, 0.0))
if (grids.size() > 20) {
grids.shift()
}
plot(grids.size())