Skip to content

Commit

Permalink
one more time
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Dec 28, 2024
1 parent a6e876f commit 13810a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmake/tools/SetupWebKit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ option(WEBKIT_VERSION "The version of WebKit to use")
option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of downloading")

if(NOT WEBKIT_VERSION)
set(WEBKIT_VERSION d90d122238e40af3e04eef8689c7abf1735df84e)
set(WEBKIT_VERSION 00e2b186fd25e79cea4cb4d63d9fd388192327f6)
endif()

if(WEBKIT_LOCAL)
Expand Down
16 changes: 12 additions & 4 deletions src/bun.js/bindings/BunProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2565,10 +2565,18 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionMemoryUsage,

result->putDirectOffset(vm, 3, JSC::jsDoubleNumber(vm.heap.extraMemorySize() + vm.heap.externalMemorySize()));

// We report 0 for this because m_arrayBuffers in JSC::Heap is private and we need to add a binding
// If we use objectTypeCounts(), it's hideously slow because it loops through every single object in the heap
// TODO: add a binding for m_arrayBuffers, registerWrapper() in TypedArrayController doesn't work
result->putDirectOffset(vm, 4, JSC::jsNumber(0));
// JSC won't count this number until vm.heap.addReference() is called.
// That will only happen in cases like:
// - new ArrayBuffer()
// - new Uint8Array(42).buffer
// - fs.readFile(path, "utf-8") (sometimes)
// - ...
//
// But it won't happen in cases like:
// - new Uint8Array(42)
// - Buffer.alloc(42)
// - new Uint8Array(42).slice()
result->putDirectOffset(vm, 4, JSC::jsDoubleNumber(vm.heap.arrayBufferSize()));

RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(result));
}
Expand Down
7 changes: 7 additions & 0 deletions test/js/node/process/process.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1056,3 +1056,10 @@ describe("process.exitCode", () => {
it("process._exiting", () => {
expect(process._exiting).toBe(false);
});

it("process.memoryUsage.arrayBuffers", () => {
const initial = process.memoryUsage().arrayBuffers;
const array = new ArrayBuffer(1024 * 1024 * 16);
array.buffer;
expect(process.memoryUsage().arrayBuffers).toBeGreaterThanOrEqual(initial + 16 * 1024 * 1024);
});

0 comments on commit 13810a0

Please sign in to comment.