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
Avoid out of memory errors when querying globals in MicroPython #1582
Comments
|
Hello, |
Does it work when you save your script as main.py and perform a soft-reboot (Ctrl+D) ? |
For shorter reprs of complex structures you might like https://github.com/alexmojaki/cheap_repr which is what birdseye uses, otherwise https://docs.python.org/3/library/reprlib.html |
@alexmojaki, thanks for the suggestions, but I'm afraid cheap_repr is too heavy for MicroPython, and Python 3 library is simply not available. |
Yes, it works as expected when saved as main.py. |
Thanks alexmojaki, not feasible in my present project but interesting for others! |
Hi Aivar, no hint for this? I can't go on developing and I guess it's a Thonny problem otherwise my code wouldn't run at all also when flashed in the ESP8266. Please tell me how can I fix this. Selecting different functions to be executed (in the same code as before) I get this other Thonny error:
|
@pyforever, did you try closing Variables table? Did this change something? How many files do you have on the board's filesystem? |
Sorry for late answer Aivar, yes i tried closing Variables table but it didn't seem to have relevant benefits. I gave a re-work to my code making it more clear and throwing some gc.collect here and there (after instancing large tables mostly) and now it seems more stable. I didn't quite change anything, only made some order in the functions libraries. However it never gave problems when run in the board, so I guess there must be something in Thonny which in some peculiar cases goes wrong. Maybe some objects in some case don't dealloc heap memory when destroyed? It's just a guess, you're the king of Thonny, of course :-) |
@pyforever, I tweaked showing global variables, such that it should take less memory now. Regarding memory problems when running code -- here we need to take into account that MicroPython also needs memory for parsing and compiling the code. When you are doing F5 in Thonny, it is less efficient. You may want to try newest MicroPython release (1.14). With this, Thonny tries to use a new and more efficient mode for submitting code. |
I installed 1.14 and trying it. I'll tell you if it goes better. |
@pyforever, please also install the fresh Thonny 3.3.4, which tries to use less memory when querying local variables: https://github.com/thonny/thonny/releases/tag/v3.3.4 |
Querying globals is refactored in Thonny 4.0 and should work much better now |
See https://groups.google.com/g/thonny/c/aXePExX2R0U
The text was updated successfully, but these errors were encountered: