[Ovmsdev] Revised memory diagnostics code

Stephen Casner casner at acm.org
Thu Nov 2 13:27:19 HKT 2017

Some more info about the revised memory diagnostics.

You can get a list of blocks owned by any of the tasks by specifying
one or more task names or ids on the module memory command.  The
output shows the task name, block size, block address, and the eight
words of the block (the first two being the malloc header):

OVMS > module memory wifi
Free 8-bit 64132/245712, 32-bit 16648/43432, blocks dumped = 10
  t=wifi s= 180 a=0x3ffe67c0  3FFE670C 810000B4 00000002 00000000 00000000 00000000 00000000 00000000
  t=wifi s= 180 a=0x3ffe670c  3FFE643C 810000B4 00000006 00000000 00000002 00000000 00000000 00000000
  t=wifi s=  56 a=0x3ffe643c  3FFE63E8 81000038 00000000 00000000 00000000 00000000 00000000 00000000
  t=wifi s=  84 a=0x3ffe63e8  3FFE64D4 81000054 00000006 00000000 00000000 00060004 00000000 00000004
  t=wifi s= 620 a=0x3ffed240  3FFED068 8100026C 3FFED070 FFFFFFFF 0000FFFF 00000000 00000000 00000000
  t=wifi s= 472 a=0x3ffed068  3FFED7EC 810001D8 00000000 FFFFFFFF 033A0279 00000000 401467AC 00000000
  t=wifi s= 104 a=0x3ffed7ec  3FFECE78 81000068 00000000 00000000 3FFED7F4 00000000 00000000 3FFED80C
  t=wifi s= 380 a=0x3ffece78  3FFEC064 8100017C 3FFECCD0 3FFECE00 5320B35D 3FFD00C8 3FFCC0D4 3FFECE80
  t=wifi s=3604 a=0x3ffec064  3FFEBFAC 81000E14 A5A5A5A5 A5A5A5A5 A5A5A5A5 A5A5A5A5 A5A5A5A5 A5A5A5A5
  t=wifi s= 184 a=0x3ffebfac  3FFEBF44 810000B8 3FFEC008 3FFEC058 3FFEC010 3FFEC00C 00000000 3FFEBFCC

If this command is given before and after some action then the later
result will separate the blocks into three lists: those freed since
the previous command, those that are still allocated, and those that
have been newly allocated since the previous command.  These are
prefixed by '-', ' ', and '+', respectively.

The "blocks dumped" value on the first line of the output tells how
many blocks were found when the command was issued.  The space set
aside to receive the list of blocks (allocated from 32-bit IRAM) is
limited to 1000 blocks.  If that limit is hit then some blocks will
not be shown.

In the previous implementation of the memory diagnostics, the blocks
for all tasks were dumped from the OS to the app storage and the total
space for each task was calculated in the app.  Hence, if there had
been more than 1000 blocks allocated the totals would not be correct.
There was an example of this in Mark's message about RAM use for
metrics structures:

> OVMS > module memory
> ============================
> Free 8-bit 85800/246632, 32-bit 18576/43548, numafter = 1000

In the revised implementation the totaling is done in the OS and
reported to the app separately from the list of blocks, and only the
blocks belonging to the selected tasks are returned.  That should make
hitting the limit less likely.

                                                        -- Steve

More information about the OvmsDev mailing list