[Microbit-Python] memory error

Alan alainjackson at hotmail.com
Thu Oct 1 02:32:14 CEST 2015


Hi,

I didn't save the version of my code that got the memory error. 

But I've just now created a small, pathological example.

The code below, which is 3kB on the disk, will create the following error:

>>> MemoryError: 
Micro Python v1.4.5-68-g3a2171e on 2015-09-04; micro:bit with nRF51822
Type "help()" for more information.

But if you delete the last line, it will run fine.




"""
Testing how much memory for python code the microbit has.
"""

from microbit import *




display.print("123456789022345678903234567890423456789052345678906234567890723456789082345678909234567890")
display.print("a12345678902234567890323456789042345678905234567890623456789072345678908234567890923456789")
display.print("ba1234567890223456789032345678904234567890523456789062345678907234567890823456789092345678")
display.print("cba123456789022345678903234567890423456789052345678906234567890723456789082345678909234567")
display.print("dcba12345678902234567890323456789042345678905234567890623456789072345678908234567890923456")
display.print("ecba12345678902234567890323456789042345678905234567890623456789072345678908234567890923456")
display.print("fecba1234567890223456789032345678904234567890523456789062345678907234567890823456789092345")
display.print("gfecba123456789022345678903234567890423456789052345678906234567890723456789082345678909234")
display.print("hgfecba12345678902234567890323456789042345678905234567890623456789072345678908234567890923")
display.print("ihgfecba1234567890223456789032345678904234567890523456789062345678907234567890823456789092")
display.print("123456789022345678903234567890423456789052345678906234567890723456789082345678909234567890")
display.print("a12345678902234567890323456789042345678905234567890623456789072345678908234567890923456789")
display.print("ba1234567890223456789032345678904234567890523456789062345678907234567890823456789092345678")
display.print("cba123456789022345678903234567890423456789052345678906234567890723456789082345678909234567")
display.print("dcba12345678902234567890323456789042345678905234567890623456789072345678908234567890923456")
display.print("ecba12345678902234567890323456789042345678905234567890623456789072345678908234567890923456")
display.print("fecba1234567890223456789032345678904234567890523456789062345678907234567890823456789092345")
display.print("gfecba123456789022345678903234567890423456789052345678906234567890723456789082345678909234")
display.print("hgfecba12345678902234567890323456789042345678905234567890623456789072345678908234567890923")
display.print("ihgfecba1234567890223456789032345678904234567890523456789062345678907234567890823456789092")
display.print("123456789022345678903234567890423456789052345678906234567890723456789082345678909234567890")
display.print("a12345678902234567890323456789042345678905234567890623456789072345678908234567890923456789")
display.print("ba1234567890223456789032345678904234567890523456789062345678907234567890823456789092345678")
display.print("cba123456789022345678903234567890423456789052345678906234567890723456789082345678909234567")
display.print("dcba12345678902234567890323456789042345678905234567890623456789072345678908234567890923456")
display.print("ecba12345678902234567890323456789042345678905234567890623456789072345678908234567890923456")
display.print("fecba1234567890223456789032345678904234567890523456789062345678907234567890823456789092345")







> Date: Wed, 30 Sep 2015 12:01:57 +0100
> From: damien.p.george at gmail.com
> To: microbit at python.org
> Subject: Re: [Microbit-Python] memory error
> 
> Hi Alan,
> 
> Can you post your code?
> 
> On Wed, Sep 30, 2015 at 2:14 AM, Alan <alainjackson at hotmail.com> wrote:
> > Hi,
> >
> > How much memory does the Microbit have for a python program?
> >
> > I've written a small program about 105 lines long. It's 3kB on my hard disk.
> > It runs ok now but when it was 115 lines long and 3.2kB I kept getting
> > memory allocation errors as soon as I pressed the reset button. If I
> > commented about 10 lines out of my program it would run and it didn't seem
> > to matter which 10 lines. So I assumed it was out of program memory?
> >
> > Cheers,
> >
> > Alan
> >
> > _______________________________________________
> > Microbit mailing list
> > Microbit at python.org
> > https://mail.python.org/mailman/listinfo/microbit
> >
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/mailman/private/microbit/attachments/20151001/f913a14f/attachment.html>


More information about the Microbit mailing list