aboutsummaryrefslogtreecommitdiff
path: root/src/allocators.py
blob: dbf26d169610e32efdc384e5ed553d1a32601cab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Default allocators using system libraries"""

import os
import subprocess

maybe_allocators = ["tcmalloc", "jemalloc", "hoard"]

allocators = {"libc": {"cmd_prefix"    : "",
                    "binary_suffix" : "",
                    "LD_PRELOAD"    : "",
                    "color"         : "C1"}}

for i, t in enumerate(maybe_allocators):
    try:
        path = subprocess.check_output('whereis lib{} | cut -d":" -f2'.format(t),
                                       shell=True, text=True).strip()

        if path != "":
            allocators[t] = {"cmd_prefix": "", "binary_suffix": "",
                          "LD_PRELOAD": path, "color": "C"+str(i+2)}
    except:
        pass