Memory Fault when allocating Thread - Garbage Collection suspected #14012
Replies: 3 comments 5 replies
-
Allocation failures can occur if the memory becomes fragmented. The attempt to allocate 4096 bytes may have failed because there isn't a free block of contiguous RAM big enough. Options are to pre-allocate and re-use buffers and to periodically issue |
Beta Was this translation helpful? Give feedback.
-
@mungewell What does this mean? How do you trigger the other thread to restart?
GC is always enabled on the official builds. As @peterhinch says, this is likely fragmentation, and the explicit collection allows the collection to happen at a more optimal time (i.e. when there are fewer live objects) which can dramatically help with fragmentation. You could also experiment with It could also be a bug (there's a lot of complexity around tracing the live objects when threads are involved) so more info would help us investigate further.
This is always the behaviour. Any failed allocation always triggers a collection, and you only see |
Beta Was this translation helpful? Give feedback.
-
I found another memory issue happening with my code, which I was able to solve. Marking this Q as solved. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a project which uses Threads, which one running on each core.
Occasionally I have to restart the thread on the 'other' core... At the time of doing this I occasionally see the following error, may occur after 5 or 6 restarts.
I am currently running on
I suspect that this is due to the garbage collection not being enabled (as per default). This does NOT occur if I force a
gc.collect()
just before re-starting the thread.https://github.com/mungewell/pico-timecode/blob/main/main.py#L217
If routinely check the memory usage I see that I am running around 65% used.
Thoughts? Perhaps the Thread code should automatically do garbage collection if the allocation fails and re-try??
Beta Was this translation helpful? Give feedback.
All reactions