diff options
author | 2023-09-21 07:25:18 -0700 | |
---|---|---|
committer | 2023-09-21 07:25:18 -0700 | |
commit | d1e9b33cac65794632921045e7a851c58ef1863d (patch) | |
tree | efca05827034d73b0481f37f7209940e266b46e6 /src/bun.js/bindings/Process.cpp | |
parent | abfc10afeb73f9447e47929359d37f2b488c3c81 (diff) | |
download | bun-d1e9b33cac65794632921045e7a851c58ef1863d.tar.gz bun-d1e9b33cac65794632921045e7a851c58ef1863d.tar.zst bun-d1e9b33cac65794632921045e7a851c58ef1863d.zip |
On Linux, respect memory limit from cgroups (#5849)
* Implement `process.constrainedMemory()`
* Add a comment
* Handle max
* Missing header
* We can use WTF::ramSize now
* Update WebKit
* Update ZigGlobalObject.cpp
* WebKit
* :scissors:
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/bindings/Process.cpp')
-rw-r--r-- | src/bun.js/bindings/Process.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index e95268fb1..c952cbef2 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -1328,6 +1328,16 @@ static Process* getProcessObject(JSC::JSGlobalObject* lexicalGlobalObject, JSVal return process; } +JSC_DEFINE_HOST_FUNCTION(Process_functionConstrainedMemory, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ +#if OS(LINUX) || OS(FREEBSD) + return JSValue::encode(jsDoubleNumber(static_cast<double>(WTF::ramSize()))); +#else + return JSValue::encode(jsUndefined()); +#endif +} + JSC_DEFINE_HOST_FUNCTION(Process_functionCpuUsage, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { @@ -1864,6 +1874,7 @@ extern "C" void Process__emitDisconnectEvent(Zig::GlobalObject* global) chdir Process_functionChdir Function 1 config constructProcessConfigObject PropertyCallback connected processConnected CustomAccessor + constrainedMemory Process_functionConstrainedMemory Function 0 cpuUsage Process_functionCpuUsage Function 1 cwd Process_functionCwd Function 1 debugPort processDebugPort CustomAccessor |