Skip to content

Simulator with print() in a tight loop consumes all RAM and page becomes unresponsive #1242

@martinwork

Description

@martinwork

Bug Description

Arising from support ticket https://support.microbit.org/helpdesk/tickets/99552 (private)

Running the simulator with a tight loop using print() consumes all RAM in less than a minute, and the page becomes unresponsive after another minute or two.

The support ticket owner reports using Linux with Firefox, and printing compass.heading()

from microbit import *
while True:
    print(compass.heading())

When I test in Windows Chrome, printing a fixed string has the same effect.

from microbit import *
while True:
    print("0"))

I don't see any RAM increase with a sleep in the loop, unless it's sleep(0).

from microbit import *
while True:
    print("0")
    sleep(1)

How To Reproduce

Steps to reproduce the behavior:

  1. Go to https://python.microbit.org/
  2. Use the code above
  3. Monitor memory consumption
  4. See error

Expected behavior

The page does not become unresponsive.

Screenshots

Image Image

Environment

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows 11
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] 148

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions