Skip to content
ChartDeck ChartScript docs Account Open the terminal

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

  • state collections 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

ChartScriptOpen in editor
//@chartscript 1
indicator("Snapshots")
state grids = array.new<matrix<float>>()
grids.push(matrix.new<float>(300, 300, 0.0))
plot(grids.size())

Fixed

ChartScriptOpen in editor
//@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())
  • CS5103 — A collection can hold at most max elements.
  • CS5404 — Stopped: the script stopped answering and was shut down.

The ChartScript documentation is in English for now; translations will follow.