[Microbit-Python] another maximum size of program thread
Locard
l0c4rd at gmail.com
Thu Jun 30 11:23:11 EDT 2016
if it helps, "stack" is how much of your allocated stack memory is being
used,
"GC" is the garbage collector, so that's dynamically-allocated memory,
but all those 'h's and 't's?
... what exactly is your program doing?
Locard
On 30/06/2016 16:20, Jeff Young wrote:
>
> That is very cool.
>
> stack: 432 out of 1800
>
> GC: total: 9600, used: 5088,.....: 451
>
> stack: 432 out of 1800
>
> GC: total: 9600, used: 5088, free: 4512stack: 432 out of 1800
>
> GC: total: 9600, used: 5088, free: 4512
>
> No. of 1 out of 1800
>
> GC: total: 9600, used: 5088, free: 4512
>
> No. of 1-out of 1800
>
> GC: total: 9600, used: 5088, free: 4512
>
> No. of 1-blocks: 7,
>
> GC: total: 9600, used: 5088, free: 4512
>
> No. of 1-blocks: 7, 2-GC: total: 9600, used: 5088, free: 4512
>
> No. of 1-blocks: 7, 2-blocks: 1, 9600, used: 5088, free: 4512
>
> No. of 1-blocks: 7, 2-blocks: 1, max blk sz: 5088,
> freeThBTL.......h.....htttttt..........htttttttt20000230:
>
> 00230: htThBTL.......h.....htttttt..........httttttttttttttttttt00230:
> htThBTL.......h.....htttttt..........htttttttttttttttttttt0230:
> ht00BTL.......h.....htttttt..........httttttttttttttttttttt....h
>
> 00630: ......h....htttttt..........httttttttttttttttttttt....h
>
> 00630: ......httttttthttt..........httttttttttttttttttttt....h
>
> 00630: ......httttttthttttthttttttttttttttttttttttttttttt....h
>
> (3 lines all free)
>
> Just need to figure out what I’m looking at ;-)
>
> *From:*Microbit
> [mailto:microbit-bounces+jeff=perfectmotion.co.uk at python.org] *On
> Behalf Of *Locard
> *Sent:* 30 June 2016 15:56
> *To:* For Pythonic MicroBit related discussions
> *Subject:* Re: [Microbit-Python] another maximum size of program thread
>
> One other thing:
> > It would be great to be able to see how much memory is being
> > consumed/free during runtime. Great to be able to see the size of
> > objects etc in memory.
> This you can do. try:
> from micropython import mem_info
> #print memory info
> mem_info()
> #print verbose memory info
> mem_info("whatever")
> Should give you the info you're after.
> Locard
>
> On 30/06/2016 15:38, Nicholas H.Tollervey wrote:
>
> I believe there is a max file length due to the constraints of the
>
> device (Mark Shannon will be able to confirm this). Perhaps you're
>
> hitting that? Why not modularise your code and import it as required in
>
> main.py..?
>
> Just guessing out loud here... YMMV.
>
> :-)
>
> N.
>
> On 30/06/16 15:35, Jeff Young wrote:
>
> Good idea. I gave it a try...
>
> Installed microfs on my PC with a 'pip install microfs'
>
> Flashed the microbit from the mu editor with a blank file. ( installed
>
> runtime)
>
> Uploaded the first test script to the microbit with 'ufs put main.py'
>
> Hit the restart button.
>
> It worked perfectly with this basic script ( main.py )
>
> from microbit import *
>
> while True:
>
> display.scroll('Hello, World!')
>
> display.show(Image.HEART)
>
> sleep(2000)
>
> Tried with my problem script getting smaller and smaller...
>
> ufs put memory.py
>
> MemoryError: memory allocation failed, allocating 3381 bytes
>
> ufs put main.py
>
> MemoryError: memory allocation failed, allocating 3087 bytes
>
> ufs put main.py
>
> MemoryError: memory allocation failed, allocating 2756 bytes
>
> I even got past the point where the SAME code loads and runs from mu ! i.e
>
> If I take the 2756bytes version above and load it into Mu and flash it
>
> works.
>
> Close but no cigar...
>
> -----Original Message-----
>
> From: Microbit [mailto:microbit-bounces+jeff=perfectmotion.co.uk at python.org]
>
> On Behalf Of Nicholas H.Tollervey
>
> Sent: 30 June 2016 14:55
>
> To:microbit at python.org <mailto:microbit at python.org>
>
> Subject: Re: [Microbit-Python] another maximum size of program thread
>
> Jeff,
>
> A quick thought. If it's script length that's the problem, you could just
>
> use the file-system. Viz:
>
> https://microbit-micropython.readthedocs.io/en/latest/tutorials/storage.html
>
> #mainly-main-py
>
> Hope this helps,
>
> N.
>
> On 30/06/16 14:47, Jeff Young wrote:
>
> Hi All
>
>
>
> First time posting here. Checked the archives and found my exact
>
> problem outlined in a thread titled 'Maximum Size of Microbit Python
>
> Program' from Jun '16.
>
> I've tried a few things and I'm hitting the 'size of script' memory
>
> problem as outlined in a post from Nicholas Tollervey. Runtime memory
>
> is fine.
>
>
>
> The program never starts and I just see;
>
>
>
> MemoryError: memory allocation failed, allocating 3688 bytes
>
> MicroPython v1.7-9-gbe020eb on 2016-04-18; micro:bit with nRF51822
>
>
>
> The thread doesn't really reach any solutions so I was wondering if
>
> anyone had found a workround ? I've tried Mu and online editors.
>
> Same result. I'm seeing the messages via REPL in Mu
>
>
>
> My program is 127 lines working but add in another 8 lines and it
>
> breaks. No comments in the code ;-)
>
>
>
> As an aside I originally wrote it using python classes and objects but
>
> found I quickly hit the runtime error limit after about 3 or 4 objects.
>
> Rewrote with simple lists and we're up to 20 objects before hitting
>
> the runtime limit. I'm thinking classes/objects consume a lot of memory.
>
> Also lists-of-lists seem quite memory hungry.
>
>
>
> It would be great to be able to see how much memory is being
>
> consumed/free during runtime. Great to be able to see the size of
>
> objects etc in memory.
>
>
>
> I'm also wondering it there is some way to re-balance the memory
>
> partitioning between the block of memory that holds the code and the
>
> runtime memory ? ie take a few kb from the run time partition and add
>
> it to the code partition ?
>
>
>
> Thanks
>
>
>
> Jeff
>
>
>
>
>
> _______________________________________________
>
> Microbit mailing list
>
> Microbit at python.org <mailto:Microbit at python.org>
>
> https://mail.python.org/mailman/listinfo/microbit
>
> are you in a meeting @be
>
> _______________________________________________
>
> Microbit mailing list
>
> Microbit at python.org <mailto:Microbit at python.org>
>
> https://mail.python.org/mailman/listinfo/microbit
>
>
>
>
> _______________________________________________
>
> Microbit mailing list
>
> Microbit at python.org <mailto: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: <http://mail.python.org/pipermail/microbit/attachments/20160630/9c43935c/attachment-0001.html>
More information about the Microbit
mailing list