Imp restarted, reason: out of memory & WS2812

I’m getting “[Exit Code] imp restarted, reason: out of memory” when running the following code in the device (nothing in agent):

// DEVICE CODE
#require “WS2812.class.nut:2.0.1”

// GLOBALS
delay <- 0.02;
spi <- hardware.spi257;
spi.configure(MSB_FIRST, 7500);
pixel <- WS2812(spi, 8);
timer <- null;

function test() {
if (timer) imp.cancelwakeup(timer);
pixel
.set(0, [100, 100, 100])
.set(1, [200, 200, 200])
.set(2, [0, 0, 100])
.set(3, [0, 100, 0])
.set(4, [100, 0, 0])
.set(5, [0, 100, 100])
.set(6, [100, 0, 100])
.set(7, [100, 100, 0])
.draw();
timer = imp.wakeup(delay, test());
}
test();

Hoping someone can pick what I’m doing wrong.
Thanks.

You are calling test rather than passing the function to imp.wakeup

Try
timer = imp.wakeup(delay,test);

BTW, you don’t really need to call imp.cancelwakeup() from within test(), as it’s a one-shot.