Skip to content

AMY seems to leak heap memory when started and stopped repeatedly. #554

@jgartrel

Description

@jgartrel

Issue summary

After being repeatedly started and stopped, AMY seems to leak heap memory. When compiled with -O3 for the nRF52840, it leaks about 520 bytes on the first iteration and 508 bytes every iteration thereafter. Eventually, this leads to a complete exhaustion of heap memory on the system.

Iteration count : 1
Heap leaked     : 540
...
Iteration count : 2
Heap leaked     : 508
...
Iteration count : 3
Heap leaked     : 508

Duplicating the issue

This issue can be duplicated using the same sample sketch detailed in issue #553


Full Serial output from tests

$ make monitor
Monitor using port: /dev/cu.usbmodem2101
Using default monitor configuration for board: shorepine:nrf52:xiaonRF52840Plus
Monitor port settings:
  baudrate=9600
  bits=8
  dtr=on
  parity=none
  rts=on
  stop_bits=1

Connecting to /dev/cu.usbmodem2101. Press CTRL-C to exit.
Board ID       : 0x817CCCA36A473E6C1D675EEAEF788915
T - Loop
 ______________________________________________
| Name | Addr 0x2000xxxx | Usage               |
| ---------------------------------------------|
| Stack| 0xF800 - 0xFFFF |   688 /  2048 (33%) |
| Heap | 0xA388 - 0xF7FF | 17236 / 218232 (07%) |
| Bss  | 0x6000 - 0xA387 | 17288               |
| SD   | 0x0000 - 0x5FFF | 24576               |
|______________________________________________|

Task    State   Prio  StackLeft Num
-----------------------------------
loop   	X	1	593	1
IDLE   	R	0	25	3
Callbac	B	2	729	2
BLE    	B	3	1195	6
SOC    	B	3	163	7
usbd   	B	3	132	5
Tmr Svc	B	2	218	4

Iteration count : 1
No sequencer support for this chip / platform
Iteration count : 1
Underrun count  : 1
I2S write count : 489
I2S write bytes : 500736
I2S write zeros : 0
Amy task count  : 489
Amy update ema  : 2893
Amy update max  : 4883
Event setup     : 7812
Amy sysclock    : 4022
Amy sample rate : 31250
Heap used       : 66396
No sequencer support for this chip / platform
Heap leaked     : 540
Heap free       : 200456
WARNING Underrun: 1
T - Loop
 ______________________________________________
| Name | Addr 0x2000xxxx | Usage               |
| ---------------------------------------------|
| Stack| 0xF800 - 0xFFFF |   688 /  2048 (33%) |
| Heap | 0xA388 - 0xF7FF | 17776 / 218232 (08%) |
| Bss  | 0x6000 - 0xA387 | 17288               |
| SD   | 0x0000 - 0x5FFF | 24576               |
|______________________________________________|

Task    State   Prio  StackLeft Num
-----------------------------------
loop   	X	1	286	1
IDLE   	R	0	25	3
BLE    	B	3	1195	6
SOC    	B	3	163	7
usbd   	B	3	132	5
Tmr Svc	B	2	218	4
Callbac	B	2	729	2

Iteration count : 2
No sequencer support for this chip / platform
Iteration count : 2
Underrun count  : 1
I2S write count : 489
I2S write bytes : 500736
I2S write zeros : 0
Amy task count  : 489
Amy update ema  : 2892
Amy update max  : 4883
Event setup     : 7813
Amy sysclock    : 4022
Amy sample rate : 31250
Heap used       : 66364
No sequencer support for this chip / platform
Heap leaked     : 508
Heap free       : 199948
WARNING Underrun: 1
T - Loop
 ______________________________________________
| Name | Addr 0x2000xxxx | Usage               |
| ---------------------------------------------|
| Stack| 0xF800 - 0xFFFF |   688 /  2048 (33%) |
| Heap | 0xA388 - 0xF7FF | 18284 / 218232 (08%) |
| Bss  | 0x6000 - 0xA387 | 17288               |
| SD   | 0x0000 - 0x5FFF | 24576               |
|______________________________________________|

Task    State   Prio  StackLeft Num
-----------------------------------
loop   	X	1	286	1
IDLE   	R	0	25	3
SOC    	B	3	163	7
Tmr Svc	B	2	218	4
usbd   	B	3	132	5
Callbac	B	2	729	2
BLE    	B	3	1195	6

Iteration count : 3
No sequencer support for this chip / platform
Iteration count : 3
Underrun count  : 1
I2S write count : 489
I2S write bytes : 500736
I2S write zeros : 0
Amy task count  : 489
Amy update ema  : 2892
Amy update max  : 4883
Event setup     : 7812
Amy sysclock    : 4022
Amy sample rate : 31250
Heap used       : 66364
No sequencer support for this chip / platform
Heap leaked     : 508
Heap free       : 199440
WARNING Underrun: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions