-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe17176
commit 4b252ab
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package jemalloc | ||
|
||
/* | ||
// This cgo directive is what actually causes jemalloc to be linked in to the | ||
// final Go executable | ||
#cgo pkg-config: jemalloc | ||
#include <jemalloc/jemalloc.h> | ||
void _refresh_jemalloc_stats() { | ||
// You just need to pass something not-null into the "epoch" mallctl. | ||
size_t random_something = 1; | ||
mallctl("epoch", NULL, NULL, &random_something, sizeof(random_something)); | ||
} | ||
int _get_jemalloc_active() { | ||
size_t stat, stat_size; | ||
stat = 0; | ||
stat_size = sizeof(stat); | ||
mallctl("stats.active", &stat, &stat_size, NULL, 0); | ||
return (int)stat; | ||
} | ||
*/ | ||
import "C" | ||
|
||
func GetActive() C.int { | ||
C._refresh_jemalloc_stats() | ||
return C._get_jemalloc_active() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters