mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Reduce concurrency when using glibc-based Linux
to help prevent memory fragmentation
This commit is contained in:
@@ -44,6 +44,7 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
||||
exports.Set("libvipsVersion", Napi::Function::New(env, libvipsVersion));
|
||||
exports.Set("format", Napi::Function::New(env, format));
|
||||
exports.Set("_maxColourDistance", Napi::Function::New(env, _maxColourDistance));
|
||||
exports.Set("_isUsingJemalloc", Napi::Function::New(env, _isUsingJemalloc));
|
||||
exports.Set("stats", Napi::Function::New(env, stats));
|
||||
return exports;
|
||||
}
|
||||
|
||||
@@ -225,3 +225,19 @@ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
|
||||
|
||||
return Napi::Number::New(env, maxColourDistance);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
// mallctl will be resolved by the runtime linker when jemalloc is being used
|
||||
extern "C" {
|
||||
int mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) __attribute__((weak));
|
||||
}
|
||||
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
return Napi::Boolean::New(env, mallctl != nullptr);
|
||||
}
|
||||
#else
|
||||
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
return Napi::Boolean::New(env, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -24,5 +24,6 @@ Napi::Value simd(const Napi::CallbackInfo& info);
|
||||
Napi::Value libvipsVersion(const Napi::CallbackInfo& info);
|
||||
Napi::Value format(const Napi::CallbackInfo& info);
|
||||
Napi::Value _maxColourDistance(const Napi::CallbackInfo& info);
|
||||
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info);
|
||||
|
||||
#endif // SRC_UTILITIES_H_
|
||||
|
||||
Reference in New Issue
Block a user