Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

[Q] how to set memory size option #447

Closed
hellower opened this issue Jun 15, 2018 · 10 comments
Closed

[Q] how to set memory size option #447

hellower opened this issue Jun 15, 2018 · 10 comments

Comments

@hellower
Copy link

hellower commented Jun 15, 2018

node --max_old_space_size=4096 myAwesomeServer.js

How can I add (max_old_space_size) options to the pkg compression binary?

cf. environment setting also not working
export NODE_OPTIONS="--max-old-space-size=2048"
./pkged_binary
Pkg: FLAGS_MISMATCH

@hellower hellower changed the title [Q] how set memory size option [Q] how to set memory size option Jun 15, 2018
@ataft
Copy link

ataft commented Nov 14, 2018

For anyone that happens upon this issue, it's in the documentation here:
https://github.com/zeit/pkg#options

How would you do this for multiple options?
Would it be like this pkg app.js --options expose-gc max_old_space_size=4096?

@jonface
Copy link

jonface commented Apr 4, 2019

Can you confirm then that this is not possible to change at runtime?

That NODE_OPTIONS or any other way will not work, for example, if I don't want to bake 'max_old_space_size' into the binary, I want to change without needing to re-package.

Thanks

@aurelhann
Copy link

Any one can confirm that?
I could be great to increase max size limit at runtime and not at the build moment.

@albanm
Copy link

albanm commented Feb 3, 2021

This is a really important point for me. I need to build the exec in a way that is compatible with low-resource machines, but allow extending memory on some more heavy-duty machines.

  • is it really impossible to define node options at runtime ?
  • if it is impossible, can it be changed by a modification of the code base (I am willing to work on a pull request) or is it too complicated because of the way pkg works ?

@yogeshbiz
Copy link

stuck on setting multiple options. does not works how ever tried. Ease any simple thing I am missing?

pkg app.js --options max-old-space-size=256 tls-min-v1.0

actually there are more options I need to add

using SET NODE_OPTIONS=--max-old-space-size=256 --tls-min-v1.0
does not works at all with multiple options.
Single quote, double quote... all variations do not work.

The compiled EXE only picks up 1 option through NODE_OPTIONS
that means 1 option baked in EXE and 1 through NODE_OPTIONS. This is not enough.

Since #447 is closed, what was resolution?

@erossignon
Copy link
Contributor

erossignon commented Apr 14, 2021

you can concatenate multiple options (no space, comma separated)

pkg app.js --options max-old-space-size=256,tls-min-v1.0

@yogeshbiz
Copy link

Thank you @erossignon. It worked.

Without clue I spend 40+ hours in 3 days taking internet down with searches and lots of experiments, all permutations.
No body on any site, stackoverflow, opensource code search engines or blog while explaining --options, used multiple options, because no one has clue.

Please include this in README file, options section.

@ilia-kebets-sonarsource

Any solution for the initial question raised by #447 (comment)?

@ilia-kebets-sonarsource

It seems to have been disabled on purpose in pkg-fetch: vercel/pkg-fetch@7f3403b

@ilia-kebets-sonarsource
Copy link

ilia-kebets-sonarsource commented Jul 19, 2023

A hello-world app works for pkg prior to this change, I tried with v5.6.0:

// hello.js
const v8 = require('node:v8');
console.log('I have so much heap RAM:', v8.getHeapStatistics().total_available_size / 1024 / 1024, 'MB');

Build binary: ./node_modules/.bin/pkg ./hello.js --targets=node16-macos-arm64

Run it:

> ./hello
> I have so much heap RAM: 4140.093421936035 MB
> NODE_OPTIONS='--max-old-space-size=2048' ./hello
> I have so much heap RAM: 2092.093421936035 MB

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants