fivem
fivem copied to clipboard
tweak(citizen-scripting-v8): increase heap size per isolate to match physical memory size
Goal of this PR
Due to the increasing amount of users using the JS runtime, some users are starting to hit the heap size limit and crashing, this increases the heap limit to match system memory, copying behavior from the mono project for sgen.
It should be notes that this caps at 4GB for some reason, I don't currently have time debug this but its likely a Node limitation.
How is this PR achieving the goal
Setting the isolate heap size to the physical memory size
This PR applies to the following area(s)
SCRT: JS
Successfully tested on
Game builds: Tested, changes aren't build specific.
Platforms: Windows, needs testing on Linux.
Checklist
- [x] Code compiles and has been tested successfully.
- [x] Code explains itself well and/or is documented.
- [x] My commit message explains what the changes do and what they are for.
- [x] No extra compilation warnings are added by these changes.
Fixes issues
Supersedes #1796
This should be fine to be reviewed, it was tested to be working fine on the client & server but still needs to be tested on Linux.
const leakMemory = [];
const isDuplicityVersion = IsDuplicityVersion();
function allocateMemory(size) {
const numbers = size / 8;
const arr = [];
arr.length = numbers;
for (let i = 0; i < numbers; i++) {
arr[i] = i;
}
return arr;
}
setInterval(() => {
if (isDuplicityVersion) {
console.log(v8.getHeapStatistics())
}
leakMemory.push(allocateMemory(100 * 1024 * 1024))
})
Thanks for your contribution, this one is tested and working for me.