-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmalloc-tools.d.ts
More file actions
84 lines (74 loc) · 3.24 KB
/
Copy pathmalloc-tools.d.ts
File metadata and controls
84 lines (74 loc) · 3.24 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Depending on which allocator is being used, the corresponding namespace will be defined
* The 'malloc' namespace is currently always defined, as it is assumed that the glibc allocator
* is always present, even if not used
*/
/** The type of allocator used: currently can be malloc or jemalloc */
export const allocator: string;
/** Get the version of glibc */
export const glibcVersion: string;
/** Structure returned by getHeapUsage() */
export interface HeapUsage {
used: number;
total: number;
}
/** Allocator-independent function to get basic heap usage statistics */
export function getHeapUsage(): HeapUsage;
export namespace malloc {
/*
* Structure returned by mallinfo() / mallinfo2()
* For more information, see manpage of mallinfo()
*/
export interface mallinfo {
arena: number; /* Total size of heap in bytes: sum of used and free space (uordblks + fordblks) */
ordblks: number;
smblks: number;
hblks: number;
hblkhd: number;
usmblks: number;
fsmblks: number;
uordblks: number; /* Total bytes in use */
fordblks: number; /* Total bytes free */
keepcost: number;
}
/**
* Binding for mallinfo2()
* NOTE: in glibc < 2.33 mallinfo2() is not present. In this case, this call maps to the deprecated
* mallinfo() function, which differs by having the values in the returned struct as 32-bit integers,
* which means that they may wrap.
*/
export function mallinfo2(): mallinfo;
/** Binding for malloc_info() */
export function info(): string;
/** Binding for malloc_stats() */
export function stats(): void;
/** Binding for malloc_trim() */
export function trim(pad: number): number;
/** glibc malloc's getHeapUsage() - even if jemalloc is used, the malloc version is
* still accessible here, in the malloc namespace. As glibc's malloc is still resident,
* together with jemalloc, it makes sense to access its stats as well
*/
export function getHeapUsage(): HeapUsage;
}
export namespace jemalloc {
/** Updates jemalloc's stats data. Without calling this, stats numbers will not update and will
* be the same every time they are queries. Therefore, this function must be called periodically
* by the js code. Note that the jemalloc's version of the common getHeapUsage() internally does
* this, so this detail is transparent for that generic API
*/
export function updateStats(): void;
/** All ctlGetXXX() / ctlSetXXX() functions map to the mallctl() interface of jemalloc,
* in read / write mode, for the corresponding type
*/
export function ctlGetSize(name: string): number;
export function ctlGetSSize(name: string): number;
export function ctlGetString(name: string): string;
export function ctlGetBool(name: string): boolean;
export function ctlGetU32(name: string): number;
export function ctlGetU64(name: string): number;
export function ctlGetUnsigned(name: string): number;
export function ctlSetSize(name: string, val: number): void;
export function ctlSetSSize(name: string, val: number): void;
export function ctlSetUnsigned(name: string, val: number): void;
export function flushThreadCache(): void;
}