/ Hex Artifact Content
Login

Artifact 296dfbce7a9ca499b95ce04e30334e64a50052e0:


0000: 23 0a 23 20 54 68 69 73 20 73 63 72 69 70 74 20  #.# This script 
0010: 6c 6f 6f 6b 73 20 66 6f 72 20 6d 65 6d 6f 72 79  looks for memory
0020: 20 6c 65 61 6b 73 20 62 79 20 61 6e 61 6c 79 7a   leaks by analyz
0030: 69 6e 67 20 74 68 65 20 6f 75 74 70 75 74 20 6f  ing the output o
0040: 66 20 22 73 71 6c 69 74 65 22 20 0a 23 20 77 68  f "sqlite" .# wh
0050: 65 6e 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 68  en compiled with
0060: 20 74 68 65 20 4d 45 4d 4f 52 59 5f 44 45 42 55   the MEMORY_DEBU
0070: 47 3d 32 20 6f 70 74 69 6f 6e 2e 0a 23 0a 2f 5e  G=2 option..#./^
0080: 6d 61 6c 6c 6f 63 20 2f 20 7b 0a 20 20 6d 65 6d  malloc / {.  mem
0090: 5b 24 35 5d 20 3d 20 24 30 0a 7d 0a 2f 5e 72 65  [$5] = $0.}./^re
00a0: 61 6c 6c 6f 63 20 2f 20 7b 0a 20 20 6d 65 6d 5b  alloc / {.  mem[
00b0: 24 37 5d 20 3d 20 22 22 3b 0a 20 20 6d 65 6d 5b  $7] = "";.  mem[
00c0: 24 39 5d 20 3d 20 24 30 0a 7d 0a 2f 5e 66 72 65  $9] = $0.}./^fre
00d0: 65 20 2f 20 7b 0a 20 20 6d 65 6d 5b 24 35 5d 20  e / {.  mem[$5] 
00e0: 3d 20 22 22 3b 0a 20 20 73 74 72 5b 24 35 5d 20  = "";.  str[$5] 
00f0: 3d 20 22 22 0a 7d 0a 2f 5e 73 74 72 69 6e 67 20  = "".}./^string 
0100: 61 74 20 2f 20 7b 0a 20 20 61 64 64 72 20 3d 20  at / {.  addr = 
0110: 24 33 0a 20 20 73 75 62 28 22 73 74 72 69 6e 67  $3.  sub("string
0120: 20 61 74 20 22 20 61 64 64 72 20 22 20 69 73 20   at " addr " is 
0130: 22 2c 22 22 29 0a 20 20 73 74 72 5b 61 64 64 72  ","").  str[addr
0140: 5d 20 3d 20 24 30 0a 7d 0a 45 4e 44 20 7b 0a 20  ] = $0.}.END {. 
0150: 20 66 6f 72 28 61 64 64 72 20 69 6e 20 6d 65 6d   for(addr in mem
0160: 29 7b 0a 20 20 20 20 69 66 28 20 6d 65 6d 5b 61  ){.    if( mem[a
0170: 64 64 72 5d 3d 3d 22 22 20 29 20 63 6f 6e 74 69  ddr]=="" ) conti
0180: 6e 75 65 0a 20 20 20 20 70 72 69 6e 74 20 6d 65  nue.    print me
0190: 6d 5b 61 64 64 72 5d 2c 20 73 74 72 5b 61 64 64  m[addr], str[add
01a0: 72 5d 0a 20 20 7d 0a 7d 0a                       r].  }.}.