Skip to content

Memory Allocation Fail with Neo Trinkey #9088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mrklingon opened this issue Mar 25, 2024 · 7 comments
Closed

Memory Allocation Fail with Neo Trinkey #9088

mrklingon opened this issue Mar 25, 2024 · 7 comments

Comments

@mrklingon
Copy link

CircuitPython version

Memory problem with CP 9.0.0 - code fails that works with CP 8.2.10

code.py output:
]0;🐍code.py | 9.0.0\Traceback (most recent call last):
File "code.py", line 1, in <module>
MemoryError: memory allocation failed, allocating 1016 bytes
]0;🐍1@code.py MemoryError | 9.0.0\
Code done running.

-------


Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
]0;🐍code.py | 8.2.10\TREK
-  .-.  .  -.-  

Code:
9.0.0

code.py: https://github.com/mrklingon/neotrinkey/blob/main/TOS3.py

Uses these modules:
https://github.com/mrklingon/neotrinkey/blob/main/morse.py
https://github.com/mrklingon/neotrinkey/blob/main/prt.py

Code/REPL

code.py output:
]0;🐍code.py | 9.0.0\Traceback (most recent call last):
File "code.py", line 1, in <module>
MemoryError: memory allocation failed, allocating 1016 bytes
]0;🐍1@code.py MemoryError | 9.0.0\
Code done running.

-------


Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
]0;🐍code.py | 8.2.10\TREK
-  .-.  .  -.-

Behavior

MemoryError: memory allocation failed, allocating 1016 bytes
]0;🐍1@code.py MemoryError | 9.0.0\

Description

Code:

code.py: https://github.com/mrklingon/neotrinkey/blob/main/TOS3.py

Uses these modules:
https://github.com/mrklingon/neotrinkey/blob/main/morse.py
https://github.com/mrklingon/neotrinkey/blob/main/prt.py

Additional information

No response

@mrklingon mrklingon added the bug label Mar 25, 2024
@tannewt tannewt added this to the 9.0.x milestone Mar 26, 2024
@dhalbert dhalbert self-assigned this Apr 1, 2024
@dhalbert
Copy link
Collaborator

dhalbert commented Apr 2, 2024

I reproduced this with 9.0.2 and 9.1.0-beta.0.

I tried this recent change to MicroPython, which allows some compilation garbage to be collected more reliably: micropython#14136. But it didn't help.

If I comment out the last four or so routines in TOS3.py (code.py), then I don't get the storage problem. So we are just over the edge.

If I use mpy-cross on TOS3.py, morse.py, and prt.py, replace the .py files with those .mpy files, and replace code.py with:

from TOS3 import *

then the program works. So I think it is probably fragmentation from code compilation. This makes sense given that we removed long-lived objects in 9.0.0.

@mrklingon So you could:

@mrklingon
Copy link
Author

Super, thanks for the update. I’ll try the mpy route - I’ve never used that before!

@dhalbert
Copy link
Collaborator

dhalbert commented Apr 2, 2024

I'm impressed by what you've been able to squeeze onto this tiny board. You might consider an RP2040 Trinkey if you want more room.

@mrklingon
Copy link
Author

Thanks, I get a kick out of squeezing as much as possible out of The NeoTrinkey. I do have one of the rp2040s - but I really like the NeoTrinkey’s four pixels for output and two pads for input :)

@mrklingon
Copy link
Author

Thanks again! I tried mpy-cross and got it working! As silly as my project may seem, I appreciate getting it to work with current CP, and as a bonus learning to use mpy-cross!!

@dhalbert
Copy link
Collaborator

dhalbert commented Apr 2, 2024

Great!

@dhalbert
Copy link
Collaborator

dhalbert commented Apr 2, 2024

I am going to close this, but thank you for the report -- it helps us understand how much the change for 8.x to 9.x affected programs on small boards.

@dhalbert dhalbert closed this as completed Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants