-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Getting the following exception:
memory allocation failed, allocating 32763 bytes
I have a bit more than 3X memory free at the time of making the call to response.text().
| def iter_content(self, chunk_size: int = 1, decode_unicode: bool = False) -> bytes: |
What I've found is that each pass through the iter_content loop is consuming 2X chunk_size (so 2X the content in total) and then at the self.close() another allocation happens for the full content size, where it throws the exception. Unclear to me if that's coming from .close or from the .join in content:
| self._cached = b"".join(self.iter_content(chunk_size=32)) |
I've found that increasing the chunk_size to 64 gets me working at a cost of 2.5X chunk_size per pass through the iter_content loop (but half as many passes).
| def iter_content(self, chunk_size: int = 1, decode_unicode: bool = False) -> bytes: |
First observed on Adafruit CircuitPython 8.2.10 on 2024-02-14; Raspberry Pi Pico W with rp2040
Also reproduced on Adafruit CircuitPython 9.0.2 on 2024-03-28; Raspberry Pi Pico W with rp2040