Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4833

MicroPython • Re: Unable to allocate memory on a raspberry pico w

$
0
0
Would that mean gc does not get invoked during compilation of a single module?
That was the basis for my view that lowering '.threshold()' might not actually achieve anything.

I honestly don't know if it does or doesn't. But, given the fact that MicroPython seems to have adopted a philosophy of only garbage collecting when necessary, not when it might be advantageous to do so, it wouldn't surprise me if it doesn't.
That doesn't make very much sense.
On one hand it may have been thought that it wasn't needed, that few would ever have source code which would make not doing garbage collection a problem, that if they did they could refactor it to avoid the problem.

It may also be an issue of how the C code within MicroPython does the compilation, allocates and uses memory. It may be that garbage collection may not improve things enough to make it worth while, or it may simply be that no one thought of adding it, and we may also be back to the previous paragraph.

There are some details on the compiler process here - https://docs.micropython.org/en/latest/develop/compiler.html - which suggest to me it's 'take it all, compile the lot'. I would therefore expect any tidy-up once done to be less effective with a large single module than with multiple smaller modules.

Assuming there isn't tidy-up along the way which would make things better, whether not having that makes sense is an interesting debate. If what there is works fine for 99.9% of cases, does it make sense to tidy-up along the way when it will only disadvantage those it works for, and the 0.1% could likely avoid the issue by refactoring ?

I am sure there would be ways to mitigate that, have the best of both worlds. but who would want to put that work in when it benefits only a rare few and there are better things to be working on which benefits everyone ?

And it is what it is. I don't blame you for creating a monolithic 'main.py' because it has advantages to do so, but it was always going to have limitations That those limitations have been hit sooner than expected, and in a way which wasn't expected, is just something you are going to have to deal with.

And please don't take that as 'victim blaming' because I detest that; you have simply walked a path which has served you well but ultimately led into a blind alley. I couldn't even say that was obviously foreseeable given the nature of the issue. It might be solvable in the future but that won't help if you need to use an older version of MicroPython.

I don't envy the position you are in. If you have been tasked with making additions by an employer it may be worth making them aware it's not as easy as it may have first seemed, that it may require a re-think on how it's done, may be a bigger challenge than initially thought.
Yes I agree with everything you're saying, I'm just trying to make the best out of my situation with the least amount of effort. I feel like there is a way to keep this going and if I end up discovering something I'll make sure to post it here for my fellow 0.1 percenters :D

Otherwise I'll need to look into some micropython zlib port but with the limited resources more likely I'll need to implement a more sophisticated "updater" module and split the code into separate modules.

Thanks again!

Statistics: Posted by pico_nub_qq — Thu Jan 16, 2025 8:57 pm



Viewing all articles
Browse latest Browse all 4833

Trending Articles