[Ovmsdev] Memory leak

Stephen Casner casner at acm.org
Mon Mar 19 23:16:56 HKT 2018


Awake again now...

Yes, the lines in 'module memory' output identified by a hex number
are ones where the scan through allocated memory blocks finds blocks
owned by a task with that TCB address but that uxTaskGetSystemState()
does not include a task with that TCB address.

The code keeps a map of TCB address to name so that it is possible to
show by name the memory belonging to tasks that have exited, but that
map only gets populated two ways:

- When 'module memory' or 'module tasks' is run

- When a task is created with the TaskBase class

- By calling AddTaskToMap() after creating a task, as I added for the
  main and Housekeeping tasks.

Michael has used TaskBase when creating a command task, so that case
would be covered.  There might be some places where we create other
tasks not using TaskBase where a call to AddTaskToMap() could be
added.  But for tasks created on our behalf by system code, those
won't be covered unless we can put the AddTaskToMap() call in our code
that causes the task to be created.

                                                        -- Steve

On Mon, 19 Mar 2018, Mark Webb-Johnson wrote:

> These are tasks that were started and then exited (leaving memory unfreed)?
>
> Regards, Mark.
>
> > On 19 Mar 2018, at 1:37 PM, Stephen Casner <casner at acm.org> wrote:
> >
> > I see there are a couple of tasks that allocated memory but did not
> > free it.  These are the tasks identified by TCB address in the module
> > memory listing:
> >
> > OVMS# mo m
> > Free 8-bit 32968/283136, 32-bit 27588/55864, SPIRAM 0/0
> > --Task--     Total DRAM D/IRAM   IRAM SPIRAM   +/- DRAM D/IRAM   IRAM SPIRAM
> > no task            5276      0      0      0      +5276     +0     +0     +0
> > esp_timer         55300      0    644      0     +55300     +0   +644     +0
> > main              40072      0      0      0     +40072     +0     +0     +0
> > ipc0              10848      0      0      0     +10848     +0     +0     +0
> > Housekeeping      17588  44112      0      0     +17588 +44112     +0     +0
> > ipc1                 12      0      0      0        +12     +0     +0     +0
> > tiT                 136   1676      0      0       +136  +1676     +0     +0
> > NetManTask            8   2196      0      0         +8  +2196     +0     +0
> > wifi                  0   1600      0      0         +0  +1600     +0     +0
> > eventTask             0  12960      0      0         +0 +12960     +0     +0
> > 3FFE3E78              0   1396      0      0         +0  +1396     +0     +0
> > Tmr Svc               0  27808      0      0         +0 +27808     +0     +0
> > 3FFEAFE4              0     88      0      0         +0    +88     +0     +0
> > AsyncConsole          0     20  27488      0         +0    +20 +27488     +0
> > OVMS# mo t
> > Number of Tasks = 16       Stack:  Now   Max Total    Heap 32-bit SPIRAM
> > Task 3FFAFAB0  1 esp_timer           0 61770 65278   55300    644      0
> > Task 3FFBDFC4  2 eventTask           0 63886 65278   12960      0      0
> > Task 3FFC6630  3 CanRxTask           0 61610 65278       0      0      0
> > Task 3FFCDA54  4 ipc0                0 64702 65278   10848      0      0
> > Task 3FFCE054  5 ipc1                0 64702 65278      12      0      0
> > Task 3FFCFE7C  8 IDLE                0 64742 65278       0      0      0
> > Task 3FFD0410  9 IDLE                0 64746 65278       0      0      0
> > Task 3FFD1DA4 10 Tmr Svc             0 61678 65278   27808      0      0
> > Task 3FFD9DC8 14 Housekeeping        0 62478 65278   61700      0      0
> > Task 3FFCE2C0 16 tiT                 0 63506 65278    1812      0      0
> > Task 3FFE327C 17 SIMCOMTask          0 61638 65278       0      0      0
> > Task 3FFF0654 22 AsyncConsole        0 62510 65278      20  27488      0
> > Task 3FFE8464 25 wifi                0 63474 65278    1600      0      0
> > Task 3FFF1828 26 pmT                 0 64398 65278       0      0      0
> > Task 3FFE82CC 29 NetManTask          0 60254 65278    2204      0      0
> > Task 3FFEC408 30 mdns                0 62906 65278       0      0      0
> > OVMS#
> >
> >                                                        -- Steve
> > _______________________________________________
> > OvmsDev mailing list
> > OvmsDev at lists.teslaclub.hk
> > http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.teslaclub.hk
> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>
>



More information about the OvmsDev mailing list