bytedance / memory-leak-detector

Other
1.09k stars 178 forks source link

部分场景raphael.py聚合的不准 #15

Closed jinshiyi11 closed 3 years ago

jinshiyi11 commented 3 years ago

部分场景raphael.py聚合的不准
比如

0x0000007010381000, 16785408, 1
0x00000000005932e0 /data/app/xxx/lib/arm64/libmya.so (unknown)
0x000000000045b8e4 /system/lib64/libsystem.so (unknown)
0x00000000000291c0 /data/app/xxx/lib/arm64/libmyb.so (unknown)

根据 group_record聚合函数,从栈底到栈顶遍历,只要是先找到了/data/下的so就返回,这种场景返回的是libmyb.so,实际应该返回libmya.so

def group_record(record):
    default = None
    for i in range(len(record.stack) - 1, -1, -1):
        match = re.match(r'.+\/(.+\.(so|apk|oat))', record.stack[i].path, re.M | re.I)
        if not match or match.group(1) == 'libraphael.so':
            continue
        elif record.stack[i].path.startswith('/data/'):
            return match.group(1)
        elif match.group(1) in system_group and not default:
            default = match.group(1)
    return default if default else 'extras'
shentianzhou commented 3 years ago

我们优化下儿

shentianzhou commented 3 years ago

已优化