Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak(citizen-scripting-v8): increase heap size per isolate to match physical memory size #2377

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AvarianKnight
Copy link
Contributor

@AvarianKnight AvarianKnight commented Feb 7, 2024

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

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

Supersedes #1796

…system memory

- This copies behavior from mono
@thorium-cfx thorium-cfx added triage Needs a preliminary assessment to determine the urgency and required action ScRT: JS Issues/PRs related to the JavaScript scripting runtime labels Feb 12, 2024
@AvarianKnight AvarianKnight marked this pull request as ready for review February 26, 2024 06:06
@AvarianKnight
Copy link
Contributor Author

AvarianKnight commented Feb 26, 2024

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))
})

@github-actions github-actions bot added invalid Requires changes before it's considered valid and can be (re)triaged triage Needs a preliminary assessment to determine the urgency and required action and removed triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ScRT: JS Issues/PRs related to the JavaScript scripting runtime triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants