Scratch - Error out of memory!!

Posted on
  • Was siting down with my 5yr old trying to blink some LEDs using scratch.
    Repeat x times doesn't seem to work
    Also looks like scratch code is run async?
    if so it's not something I can teach my kid I struggle myself!
    Would be good to see the js code that scratch creates.

    Anyway in my floundering around (image attached) I got this

    ERROR: Out of Memory!
    ERROR: Out of Memory!
    WARNING: Unable to create string as not enough memory
    ERROR: Out of Memory!
    WARNING: Unable to create string as not enough memory
    ERROR: Out of Memory!
    WARNING: Unable to create string as not enough memory
    ERROR: Out of Memory!
    WARNING: Out of memory while appending to array
    ERROR: Out of Memory!
    at line 5 col 17

     }, 2*1000.0);

    in function called from system
    Execution Interrupted during event processing - clearing all timers and watches.

    1 Attachment

    • 7dd06c65c86ded275fb54445ddeb3a9018dca68d.png
  • You can get the code by:

    • right click in orange area on top of edit window
    • in upcomin list click on 3rd item (in german element untersuchen), something like watch element
    • you should now get a new chrome window
    • click on console and you will see a lot
    • at the end there should be something like Sending... clearInterval();clearWatch();setWatch(fu­nction() {.....
      This is javascript which is sent to espruino.
      You will see setTimeout and this is called 10 times, without waiting for completion before running loop next time.
  • @JumJum: That'll only work if you're using the version you install from GitHub - not the one from the web store.

    @controlCloud: Ok, I just got the out of memory by tapping the button 5 times very quickly - is that what you did?

    But yes, the code that's produced is async - when you say 'wait 2 seconds' it actually executes the bit inside it after 2 seconds, while executing the next bit down immediately. So what you're doing is immediately asking 20 different digitalWrites to be done after 2 seconds. If you press the button 5 times that's creating 100 different callbacks!

    If you want to flash, then I'd drag the second wait to be inside the first wait. Repeating 10 times is more tricky, but can be done with something like the attached. Obviously if you keep pressing the button it'll have pretty much the same effect and will run out of memory though (however after roughly twice the number of button presses).

    1 Attachment

    • a672084360d1e6e8d49306d09f7dfefed824f7a7.png
  • I don't know it hit the button but it's bricked I can connect it won't run I deleted scratch code and just trying to use the simple toggle javascript example nothing. Rebooted any ideas?

  • Is the blue led glowing? If so it'll be because BTN1 was pressed when you hit reset or plugged it in and it went to bootloader mode - just try pressing the RST button again (with the Web IDE disconnected).

    Have you tried rebooting your computer (not sure if you meant you'd rebooted the PC or Espruino)? Sometimes windows gets confused if you reset the board with the Web IDE connected.

  • Otherwise there's some info here:

    Did you ever type save() at all?

  • Gordon been busy plugged in and all back working.
    And thanks I have olimex Robot for half term fun with my 5yr old :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Scratch - Error out of memory!!

Posted by Avatar for LawrenceGrif @LawrenceGrif