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

MicroPython • Re: Viability of Pico W as a network device

$
0
0
I've done precisely two projects with the picoW (one public, one not) so my experience is somewhat limited.

I've done no memory profiling on the public one but haven't encountered any memory related problems despite using a roll your own web server.

The other project uses urequests to scrape data from a web page. With that one I found it necessary to force a garbage collection at the start and end of the scrape function or I'd hit out of memory errors.

Some things I learned that aren't immediately obvious. Appologies if you already know these:
  1. Unlike C/C++ code, micropython does not run your program driectly from the flash storage. It first compiles it to byte code and runs that from RAM.
  2. Garbage collection is not a constant background process. It only happens when either you call it or you attempt to allocate memory. And judging by experience not always then.
  3. It was possible to use a periodic timer to force a regular garbage collection.
  4. As with "normal" python, strings are immutable. If you do lots of string manipulation you create lots of garbage (changing a string throws away the old version and creates a new one).

Statistics: Posted by thagrol — Sat Jan 13, 2024 12:55 pm



Viewing all articles
Browse latest Browse all 4923

Trending Articles