commit 8dfe8c9325f7a126011f97209ba797b1ef5dd171 from: Matthias L. Jugel date: Tue Jan 15 14:10:28 2019 UTC how to configure commit - a9b4e7601cbf521026dbc67adabc41e54cc9fc50 commit + 8dfe8c9325f7a126011f97209ba797b1ef5dd171 blob - e5501eed5fb859a9ec85c5172f296884f5716946 blob + fa40c625c8ccf5891beb2fa72443c3d8fc286b38 --- README.md +++ README.md @@ -9,79 +9,58 @@ If you look for the original memtrace, check out the m Run with: `python3 memtrace.py /dev/cu.XXXXX 115200` +To make full use of this script, configure your microbit-dal as follows: + +```json +{ + "microbit-dal": { + "debug": 1, + "heap_debug": 1, + "panic_on_heap_full": 1 + } +} +``` + The script auto-resets the counts and output looks like: ``` +HEAP 0: +heap_start : 0x20002950 +heap_end : 0x20003800 +heap_size : 3760 + >> RESET HEAP COUNTERS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - (NUM) TOTAL [ ADDRESS] CHANGE (COMMENT) + (NUM) FREE [ ADDRESS] CHANGE (COMMENT) [F:3760] mb_total_free : 3760 mb_total_used : 0 == (001) 3704 [20002954] +56 (malloc: ALLOCATED: 56 [0x20002954]) == (002) 3684 [20002990] +20 (malloc: ALLOCATED: 20 [0x20002990]) == (003) 3636 [200029a8] +48 (malloc: ALLOCATED: 48 [0x200029a8]) -== (004) 3620 [200029dc] +16 (malloc: ALLOCATED: 16 [0x200029dc]) -== (005) 3580 [200029f0] +40 (malloc: ALLOCATED: 40 [0x200029f0]) -== (006) 3556 [20002a1c] +24 (malloc: ALLOCATED: 24 [0x20002a1c]) -== (007) 3516 [20002a38] +40 (malloc: ALLOCATED: 40 [0x20002a38]) -== (008) 3492 [20002a64] +24 (malloc: ALLOCATED: 24 [0x20002a64]) -== (009) 3484 [20002a80] +8 (malloc: ALLOCATED: 8 [0x20002a80]) -== (010) 3476 [20002a8c] +8 (malloc: ALLOCATED: 8 [0x20002a8c]) -== (011) 3384 [20002a98] +92 (malloc: ALLOCATED: 92 [0x20002a98]) -== (012) 3376 [20002af8] +8 (malloc: ALLOCATED: 8 [0x20002af8]) -== (013) 3368 [20002b04] +8 (malloc: ALLOCATED: 8 [0x20002b04]) -== (014) 3256 [20002b10] +112 (malloc: ALLOCATED: 112 [0x20002b10]) -== (015) 3216 [20002b84] +40 (malloc: ALLOCATED: 40 [0x20002b84]) -== (016) 3192 [20002bb0] +24 (malloc: ALLOCATED: 24 [0x20002bb0]) -== (017) 3179 [20002bcc] +13 (malloc: ALLOCATED: 13 [0x20002bcc]) -== (018) 3087 [20002be0] +92 (malloc: ALLOCATED: 92 [0x20002be0]) -== (019) 2995 [20002c40] +92 (malloc: ALLOCATED: 92 [0x20002c40]) -== (020) 2955 [20002ca0] +40 (malloc: ALLOCATED: 40 [0x20002ca0]) -== (021) 2915 [20002ccc] +40 (malloc: ALLOCATED: 40 [0x20002ccc]) -== (022) 2903 [20002cf8] +12 (malloc: ALLOCATED: 12 [0x20002cf8]) -== (023) 2863 [20002d08] +40 (malloc: ALLOCATED: 40 [0x20002d08]) -== (024) 2839 [20002d34] +24 (malloc: ALLOCATED: 24 [0x20002d34]) +... == (025) 2815 [20002d50] +24 (malloc: ALLOCATED: 24 [0x20002d50]) == (026) 2591 [20002d6c] +224 (malloc: ALLOCATED: 224 [0x20002d6c]) -!! (026) WARN: free(0x0x20002d50) -== (026) 2591 [ 0] -0 (free: 0x20002d50) -== (026) 2581 [20002d50] +10 (malloc: ALLOCATED: 10 [0x20002d50]) -== (027) 2571 [20002e50] +10 (malloc: ALLOCATED: 10 [0x20002e50]) -== (028) 2561 [20002e60] +10 (malloc: ALLOCATED: 10 [0x20002e60]) -== (029) 2546 [20002e70] +15 (malloc: ALLOCATED: 15 [0x20002e70]) -!! (029) WARN: free(0x0x20002e60) -== (029) 2546 [ 0] -0 (free: 0x20002e60) -!! (029) WARN: free(0x0x20002e50) -== (029) 2546 [ 0] -0 (free: 0x20002e50) -== (029) 2528 [20002e50] +18 (malloc: ALLOCATED: 18 [0x20002e50]) -== (030) 2521 [20002d60] +7 (malloc: ALLOCATED: 7 [0x20002d60]) -== (031) 2515 [20002e84] +6 (malloc: ALLOCATED: 6 [0x20002e84]) -== (032) 2495 [20002e90] +20 (malloc: ALLOCATED: 20 [0x20002e90]) -== (033) 2470 [20002ea8] +25 (malloc: ALLOCATED: 25 [0x20002ea8]) -== (034) 2444 [20002ec8] +26 (malloc: ALLOCATED: 26 [0x20002ec8]) -!! (034) WARN: free(0x0x20002e50) -== (034) 2444 [ 0] -0 (free: 0x20002e50) -!! (034) WARN: free(0x0x20002ea8) -== (034) 2444 [ 0] -0 (free: 0x20002ea8) -!! (034) WARN: free(0x0x20002e90) -== (034) 2444 [ 0] -0 (free: 0x20002e90) -== (034) 2436 [20002e50] +8 (malloc: ALLOCATED: 8 [0x20002e50]) -== (035) 2116 [20002ee8] +320 (malloc: ALLOCATED: 320 [0x20002ee8]) -== (036) 2108 [20002e5c] +8 (malloc: ALLOCATED: 8 [0x20002e5c]) -== (036) 2088 [20002e90] +20 (malloc: ALLOCATED: 20 [0x20002e90]) -== (037) 1476 [2000302c] +612 (malloc: ALLOCATED: 612 [0x2000302c]) -== (037) 1456 [20002ea8] +20 (malloc: ALLOCATED: 20 [0x20002ea8]) -== (038) 1436 [20003294] +20 (malloc: ALLOCATED: 20 [0x20003294]) -== (039) 1400 [200032ac] +36 (malloc: ALLOCATED: 36 [0x200032ac]) -!! (039) WARN: free(0x0x20002e84) -== (039) 1400 [ 0] -0 (free: 0x20002e84) -!! (039) WARN: free(0x0x20002d60) -== (039) 1400 [ 0] -0 (free: 0x20002d60) -!! (039) WARN: free(0x0x20002ec8) -== (039) 1400 [ 0] -0 (free: 0x20002ec8) -!! (039) WARN: free(0x0x20002e70) -== (039) 1400 [ 0] -0 (free: 0x20002e70) -== (040) 1365 [20002e68] +35 (malloc: ALLOCATED: 35 [0x20002e68]) -== (041) 1344 [20002ec0] +21 (malloc: ALLOCATED: 21 [0x20002ec0]) +== (025) 2615 [20002d50] -24 (free: 0x20002d50) +!! (025) WARN: free(0x0) +== (025) 2615 [ 0] -0 (free: 0) +... +== (039) 1438 [20002ec0] +31 (malloc: ALLOCATED: 31 [0x20002ec0]) +== (038) 1478 [200032f4] -40 (free: 0x200032f4) +== (037) 1509 [20002ec0] -31 (free: 0x20002ec0) +== (038) 1081 [200032f4] +428 (malloc: ALLOCATED: 428 [0x200032f4]) +!! (038) : malloc(): no free block of size 1024 +HEAP ALLOCATION (% header | * data | . free) +000000 20002950 %%%%********************************************************%%%% +000064 20002990 ********************%%%%**************************************** +... +001280 20002e50 ********%%%%********%%%%********************................%%%% +001344 20002e90 ********************%%%%********************.................... +001408 20002ed0 ....................%%%%**************************************** +001472 20002f10 **************************************************************** +... +== Free blocks: == +20002e7c 16 bytes +20002ebc 40 bytes +200034a0 864 bytes ``` ## License