z3ugma
08/06/2025, 6:26 PMHeap report @ out of memory in primitive 8:2:
┌───────────┬──────────┬─────────────────────────────────────────────────────┐
│ Bytes │ Count │ Type │
├───────────┼──────────┼─────────────────────────────────────────────────────┤
│ 5648 │ 513 │ heap overhead │
│ 173528 │ 467 │ untagged │
└───────────┴──────────┴─────────────────────────────────────────────────────┘
Total: 179176 bytes in 467 allocations (53%), largest free 116k, total free 152k
******************************************************************************
MALLOC_FAILED error.
0: S6d05a1.draw-test-pattern s6d05a1.toit:560:20
1: main.<block> display_new.toit:43:12
2: SmallInteger_.repeat <sdk>/core/numbers.toit:1288:3
3: main display_new.toit:42:5
******************************************************************************
I can reliably make this memory allocation fail by commenting and uncommenting a line in this code:
main:
print "initializing display..."
driver := S6d05a1 bus cs 320 320 --reset=reset
5.repeat:
driver.draw-test-pattern
sleep --ms=600z3ugma
08/06/2025, 6:26 PMdraw-test-pattern:
start:= Time.monotonic-us
left := random 0 250
right := left + 75
top := random 0 250
bottom := top + 75
set-range_ CMD-CASET_ top bottom
set-range_ CMD-RASET_ left right
color := random 255
print "Color: $color"
bluary := #[color, color, color, color, color, color, 0,0]
chomps := #[]
times := 12
times.repeat:
chomps += chomp bluary
device_.transfer --command=0 #[0x2C]
device_ = bus_.device --cs=cs_ --frequency=6_000_000
//Here is where we shift into manually having calculated the 9-bit arrays called Chomps
//Set the device back
device_ = bus_.device --cs=cs_ --command-bits=1 --frequency=100_000
end := Time.monotonic-us
print "Duration: $((end - start) / 1_000) ms"z3ugma
08/06/2025, 6:26 PMdevice_ = bus_.device --cs=cs_ --frequency=6_000_000z3ugma
08/06/2025, 6:26 PMMALLOC_FAILED error.
0: S6d05a1.draw-test-pattern s6d05a1.toit:560:20
1: main.<block> display_new.toit:43:12
2: SmallInteger_.repeat <sdk>/core/numbers.toit:1288:3
3: main display_new.toit:42:5z3ugma
08/06/2025, 6:28 PMz3ugma
08/06/2025, 6:29 PM--command flag but it slows down drawing significantly vs packing my own byte arrays and using device.transferz3ugma
08/06/2025, 6:30 PMfloitsch
08/06/2025, 6:31 PMz3ugma
08/06/2025, 6:32 PMdevice_ to a new instance of the SPI primitive then it runs OOMfloitsch
08/06/2025, 6:33 PMfloitsch
08/06/2025, 6:33 PMz3ugma
08/06/2025, 6:33 PMz3ugma
08/06/2025, 6:34 PMz3ugma
08/06/2025, 6:34 PMfloitsch
08/06/2025, 6:34 PMfloitsch
08/06/2025, 6:34 PMfloitsch
08/06/2025, 6:35 PMfloitsch
08/06/2025, 6:35 PMz3ugma
08/06/2025, 6:36 PMHeap report @ out of memory in primitive 8:2:
┌───────────┬──────────┬─────────────────────────────────────────────────────┐
│ Bytes │ Count │ Type │
├───────────┼──────────┼─────────────────────────────────────────────────────┤
│ 4112 │ 3 │ external byte array │
│ 45056 │ 13 │ toit processes │
│ 16384 │ 4 │ system 0 c6e1701e-f05b-c078-c7ca-86c80db24c59 │
│ 20480 │ 5 │ other 1 e83e33a6-0922-fccf-aef3-e6d2215dfaef │
│ 8192 │ 2 │ current 3 512c9a75-e49f-7a4b-0f71-b2f7206ac0bb │
│ 16384 │ 1 │ heap metadata │
│ 4096 │ 1 │ spare new-space │
│ 6280 │ 30 │ lwip │
│ 6224 │ 476 │ heap overhead │
│ 2192 │ 33 │ event source │
│ 7848 │ 129 │ thread/other │
│ 26400 │ 21 │ thread/spawn │
│ 50944 │ 161 │ untagged │
│ 11608 │ 50 │ wifi │
└───────────┴──────────┴─────────────────────────────────────────────────────┘
Total: 181144 bytes in 440 allocations (75%), largest free 32k, total free 58k
***********************************************************
MALLOC_FAILED error.
0: S6d05a1.draw-test-pattern s6d05a1.toit:555:20
1: main.<block> display_new.toit:43:12
2: SmallInteger_.repeat <sdk>/core/numbers.toit:1288:3
3: main display_new.toit:42:5floitsch
08/06/2025, 6:37 PMsystem.print-objects. Makes it easier to see whether there are leaks.
- esp32.memory-page-report. Makes it easier to detect fragmentation.
- esp32.dump-heap. Big fat dump of how Toit sees the memory.
And system.serial-print-heap-report prints something similar to what happens when there is an OOM.floitsch
08/06/2025, 6:38 PMfloitsch
08/06/2025, 6:39 PMfloitsch
08/06/2025, 6:40 PMfloitsch
08/06/2025, 6:41 PMfloitsch
08/06/2025, 6:42 PMclose is preferred.z3ugma
08/06/2025, 6:43 PMclose did the trick.floitsch
08/06/2025, 6:43 PMfloitsch
08/06/2025, 6:44 PMz3ugma
08/06/2025, 6:46 PMclose
https://cdn.discordapp.com/attachments/1402719429430870088/1402724476650782770/message.txt?ex=6894f478&is=6893a2f8&hm=692737ba4cd6bc0e0bb01b4804f5a6e9afcd677db72c9bb56196124c6c14c941&z3ugma
08/06/2025, 6:48 PMHeap report @ out of memory in primitive 8:2:
┌───────────┬──────────┬─────────────────────────────────────────────────────┐
│ Bytes │ Count │ Type │
├───────────┼──────────┼─────────────────────────────────────────────────────┤
│ 4192 │ 12 │ external byte array │
│ 45056 │ 13 │ toit processes │
│ 16384 │ 4 │ system 0 c6e1701e-f05b-c078-c7ca-86c80db24c59 │
│ 20480 │ 5 │ other 1 e83e33a6-0922-fccf-aef3-e6d2215dfaef │
│ 8192 │ 2 │ current 12 3aa61f86-aee4-8c91-982a-f143894a47d0 │
│ 16384 │ 1 │ heap metadata │
│ 4096 │ 1 │ spare new-space │
│ 6256 │ 29 │ lwip │
│ 6368 │ 494 │ heap overhead │
│ 2192 │ 33 │ event source │
│ 8032 │ 136 │ thread/other │
│ 26400 │ 21 │ thread/spawn │
│ 50912 │ 160 │ untagged │
│ 11608 │ 50 │ wifi │
└───────────┴──────────┴─────────────────────────────────────────────────────┘
Total: 181496 bytes in 454 allocations (76%), largest free 28k, total free 58k
******************************************************************************
MALLOC_FAILED error.
0: S6d05a1.draw-test-pattern s6d05a1.toit:563:20
1: main.<block> display_new.toit:45:12
2: SmallInteger_.repeat <sdk>/core/numbers.toit:1288:3
3: main display_new.toit:43:6
******************************************************************************z3ugma
08/06/2025, 6:48 PMz3ugma
08/06/2025, 6:49 PMz3ugma
08/06/2025, 6:51 PMdevice_.close
device_ = bus_.device --cs=cs_ --frequency=6_000_000
//((left - right) * (top - bottom) / 8 * 3 / times).repeat:
// device_.transfer chomps
if I comment those lines back in then I get a MALLOC_FAILED. I will add in those 3 lines and try to get a file attached herefloitsch
08/06/2025, 6:53 PMz3ugma
08/06/2025, 7:08 PMfloitsch
08/07/2025, 9:49 PM