-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
maxMemoryLimitBeforeRecycle
options
- Loading branch information
1 parent
977df66
commit 8e39223
Showing
6 changed files
with
77 additions
and
5 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
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
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,17 @@ | ||
export let leaks = [] | ||
|
||
/** | ||
* Leak some memory to test memory limit usage. | ||
* The argument `bytes` is not 100% accurate of the leaked bytes but good enough. | ||
*/ | ||
export default function run(bytes) { | ||
const before = process.memoryUsage().heapUsed | ||
|
||
for (const _ of Array(bytes).fill()) { | ||
leaks.push(new SharedArrayBuffer(1024)) | ||
} | ||
const after = process.memoryUsage().heapUsed | ||
const diff = after - before | ||
|
||
console.log(`Leaked: ${diff}. Heap used: ${process.memoryUsage().heapUsed}`) | ||
} |
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