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

import subprocess

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

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

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

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