@@ -48,11 +48,11 @@ This crate provides following cargo feature flags:
48
48
* ` stats ` (configure ` jemalloc ` with ` --enable-stats ` ): Enable statistics
49
49
gathering functionality. See the ` jemalloc ` 's "` opt.stats_print ` " option
50
50
documentation for usage details.
51
-
51
+
52
52
* ` debug ` (configure ` jemalloc ` with ` --enable-debug ` ): Enable assertions and
53
53
validation code. This incurs a substantial performance hit, but is very useful
54
54
during application development.
55
-
55
+
56
56
* ` background_threads_runtime_support ` (enabled by default): enables
57
57
background-threads run-time support when building ` jemalloc-sys ` on some POSIX
58
58
targets supported by ` jemalloc ` . Background threads are disabled at run-time
@@ -72,16 +72,36 @@ This crate provides following cargo feature flags:
72
72
* ` unprefixed_malloc_on_supported_platforms ` : when disabled, configure
73
73
` jemalloc ` with ` --with-jemalloc-prefix=_rjem_ ` . Enabling this causes symbols
74
74
like ` malloc ` to be emitted without a prefix, overriding the ones defined by
75
- libc. This usually causes C and C++ code linked in the same program to use
76
- ` jemalloc ` as well. On some platforms prefixes are always used because
77
- unprefixing is known to cause segfaults due to allocator mismatches.
78
-
75
+ libc. This usually causes C, Objective-C and C++ code linked in the same
76
+ program to use ` jemalloc ` as well. On some platforms prefixes are always used
77
+ because unprefixing is known to cause segfaults due to allocator mismatches.
78
+
79
+ Note that to use this, the ` jemalloc-sys ` crate must actually be visible to
80
+ ` rustc ` (it is not enough to only declare it in ` Cargo.toml ` ). This can be
81
+ done with:
82
+ ``` rust
83
+ use jemalloc_sys as _;
84
+ ```
85
+
86
+ On macOS, you'll need to do a bit more to work around a bug in ` rustc ` :
87
+ ``` rust
88
+ // Workaround for https://github.com/rust-lang/rust/issues/133491
89
+ #[cfg(target_vendor = " apple" )]
90
+ #[used]
91
+ static USED_ZONE_REGISTER : unsafe extern " C" fn () = {
92
+ extern " C" {
93
+ fn _rjem_je_zone_register ();
94
+ }
95
+ _rjem_je_zone_register
96
+ };
97
+ ```
98
+
79
99
* ` disable_initial_exec_tls ` (disabled by default): when enabled, jemalloc is
80
- built with the ` --disable-initial-exec-tls ` option. It disables the
81
- initial-exec TLS model for jemalloc's internal thread-local storage (on those
82
- platforms that support explicit settings). This can allow jemalloc to be
100
+ built with the ` --disable-initial-exec-tls ` option. It disables the
101
+ initial-exec TLS model for jemalloc's internal thread-local storage (on those
102
+ platforms that support explicit settings). This can allow jemalloc to be
83
103
dynamically loaded after program startup (e.g. using dlopen). If you encounter
84
- the error ` yourlib.so: cannot allocate memory in static TLS block ` , you'll
104
+ the error ` yourlib.so: cannot allocate memory in static TLS block ` , you'll
85
105
likely want to enable this.
86
106
87
107
* ` disable_cache_oblivious ` (disabled by default): when enabled, jemalloc is
@@ -104,7 +124,7 @@ hyphens `-` are replaced with underscores `_`(see
104
124
variable, the ` /etc/malloc.conf ` symlink, and the ` MALLOC_CONF ` environment
105
125
variable (note: this variable might be prefixed as ` _RJEM_MALLOC_CONF ` ). For
106
126
example, to change the default decay time for dirty pages to 30 seconds:
107
-
127
+
108
128
```
109
129
JEMALLOC_SYS_WITH_MALLOC_CONF=dirty_decay_ms:30000
110
130
```
@@ -115,17 +135,17 @@ hyphens `-` are replaced with underscores `_`(see
115
135
allocator page size equal to the system page size, so this option need not be
116
136
specified unless the system page size may change between configuration and
117
137
execution, e.g. when cross compiling.
118
-
138
+
119
139
* ` JEMALLOC_SYS_WITH_LG_HUGEPAGE=<lg-hugepage> ` : Specify the base 2 log of the
120
140
system huge page size. This option is useful when cross compiling, or when
121
141
overriding the default for systems that do not explicitly support huge pages.
122
-
123
-
142
+
143
+
124
144
* ` JEMALLOC_SYS_WITH_LG_QUANTUM=<lg-quantum> ` : Specify the base 2 log of the
125
145
minimum allocation alignment. jemalloc needs to know the minimum alignment
126
146
that meets the following C standard requirement (quoted from the April 12,
127
147
2011 draft of the C11 standard):
128
-
148
+
129
149
> The pointer returned if the allocation succeeds is suitably aligned so that
130
150
> it may be assigned to a pointer to any type of object with a fundamental
131
151
> alignment requirement and then used to access such an object or an array of
0 commit comments