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

Cannot change --max-old-space-size #153

Open
richard-keller-olivia opened this issue Aug 24, 2021 · 2 comments
Open

Cannot change --max-old-space-size #153

richard-keller-olivia opened this issue Aug 24, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@richard-keller-olivia
Copy link

Hello,

I am trying to adjust the node heap limit of my app running on bytenode, but I couldn't.

Steps to reproduce:

Create a test.js file:
console.log(`node heap limit = ${ require('v8').getHeapStatistics().heap_size_limit / (1024 * 1024) } Mb`)

Execution using node:
node test.js
Output
node heap limit = 2096 Mb

Execution using node with --max-old-space-size:
node --max-old-space-size=7500 test.js
Output
node heap limit = 7548 Mb

Execution using bytenode:
node --max-old-space-size=7500 node_modules/bytenode/lib/cli.js ./test.jsc
Output
node heap limit = 2096 Mb

Execution using bytenode sending --max-old-space-size:
node node_modules/bytenode/lib/cli.js ./test.jsc --max-old-space-size=7500
Output
node heap limit = 2096 Mb

So my next attempt was to fork a process sending --max-old-space-size on execArgv:

console.log(`node heap limit = ${ require('v8').getHeapStatistics().heap_size_limit / (1024 * 1024) } Mb`)

const cluster = require('cluster');
if (cluster.isMaster) {
  cluster.setupMaster({
    execArgv: ['--max-old-space-size=7500'],
  });
  cluster.fork();
}

node test.js
Output:

node heap limit = 2096 Mb
node heap limit = 7548 Mb

If I execute the same code using bytenode:

node heap limit = 2096 Mb
test.jsc:1
���$S�:J


SyntaxError: Invalid or unexpected token
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47```
@OsamaAbbas
Copy link
Collaborator

This should work:

node --max-old-space-size=7500 -r bytenode test.jsc

Given that bytenode is installed locally.

@OsamaAbbas
Copy link
Collaborator

This bug should be fixed in cli.js. Thank you for reporting.

@OsamaAbbas OsamaAbbas added the bug Something isn't working label Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants