smartbutnot / flightportal

Project for displaying the details of planes overhead on an Adafruit MatrixPortal and LED matrix
267 stars 25 forks source link

Memory allocation error #12

Closed felker closed 1 year ago

felker commented 1 year ago

Ok, last issue from me, I swear :)

I sometimes get errors like

"MemoryError: memory allocation failed, allocating 12850 bytes" (even as low as 8291 bytes).

at line https://github.com/smartbutnot/flightportal/blob/8519ea53f9eaa2747a170a590496c3889f08d563/code.py#L236

In the 8291 byte failure, byte_counter=6148 and trail_start=6045, for example.

I made some modifications to the code to support some external switches I wired in, so I might be using extra memory that the base code does not, although I think I also observed this with your code. Any tips on how to avoid this?

felker commented 1 year ago

I think this avoids a copy of a subset of the static array:

trail_end=json_bytes.find((b"}"), trail_start) - trail_start