PyBasic icon indicating copy to clipboard operation
PyBasic copied to clipboard

Fix for memory leak

Open grwhitehead opened this issue 1 year ago • 3 comments

Fix for bug where "IF THEN " statements were leaving the line number on the operand stack, causing a memory leak

grwhitehead avatar Oct 14 '24 15:10 grwhitehead

This looks good to me. I'm excited to test it out later tonight and see if it resolves issues I've been having running adventure especially on microcontrollers with limited ram. Thanks so much!!!

RetiredWizard avatar Oct 14 '24 18:10 RetiredWizard

No problem, thanks for your work on PyBasic! Running code on a microcontroller with limited ram was exactly what tripped me up. This was my first time debugging a memory leak in python and I found guppy3 to be invaluable.

On Mon, Oct 14, 2024 at 11:08 AM RetiredWizard @.***> wrote:

This looks good to me. I'm excited to test it out later tonight and see if it resolves issues I've been having running adventure especially on microcontrollers with limited ram. Thanks so much!!!

— Reply to this email directly, view it on GitHub https://github.com/richpl/PyBasic/pull/67#issuecomment-2411931255, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYZFRQ4WUY6KLBINSAMRBTZ3QCCVAVCNFSM6AAAAABP5IO27KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJRHEZTCMRVGU . You are receiving this because you authored the thread.Message ID: @.***>

grwhitehead avatar Oct 14 '24 18:10 grwhitehead

I tested on a Pico running adventure and was able to play far into the dungeon without a memory crash. Before this update, I would get a memory allocation error on a Pico about a dozen moves into the game.

By the way, if you're running PyBasic on a microcontoller, I created a version that doesn't load the basic program into RAM but runs it directly off the flash. This really makes a big difference in the size of basic programs that will load and run. It runs a little slower and there are a couple of other minor changes but it should be pretty compatible.

RetiredWizard avatar Oct 14 '24 20:10 RetiredWizard

Many thanks for this @grwhitehead. It's been a while since I worked on this so I always appreciate someone creating a PR when they've found a bug!

richpl avatar Oct 25 '24 13:10 richpl