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

Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory #137

Open
Yusufkulcu opened this issue Sep 26, 2024 · 6 comments
Labels
enhancement New feature or request scope: unminify

Comments

@Yusufkulcu
Copy link

Yusufkulcu commented Sep 26, 2024

Describe the bug

When I use the "npx @wakaru/cli unminify" command in my js file, it gives the following error. The computer I use is extremely powerful. What should I do? I've added the relevant file below.

"Since the javascript file was not loaded, I set the extension to txt"

image

main.txt

Input code

No response

Reproduction

No response

Steps to reproduce

No response

Expected behavior

no memory error

Actual behavior

No response

@0xdevalias
Copy link

@Yusufkulcu Dumb question.. but did you try it again following the instructions in the warning message shown in your screenshot about how to potentially resolve out of memory issues by using the --max-old-space-size?

If you googled "node js heap out of memory" or similar you would also turn up results like this, which also talk about using --max-old-space-size:

@pionxzh
Copy link
Owner

pionxzh commented Sep 27, 2024

The solution is to follow the instructions in the message. I think the instructions are not step-by-step, so let me give one here.

MacOS / Linux

NODE_OPTIONS="--max-old-space-size=8192" npx @wakaru/cli unminify

Windows (CMD)

set NODE_OPTIONS=--max-old-space-size=8192 && npx @wakaru/cli unminify

8192 in the command is 8GB. You can adjust the number based on your PC's specs and the size of the file.

BTW, what is the size of your input file?

@Yusufkulcu
Copy link
Author

The solution is to follow the instructions in the message. I think the instructions are not step-by-step, so let me give one here.

MacOS / Linux

NODE_OPTIONS="--max-old-space-size=8192" npx @wakaru/cli unminify

Windows (CMD)

set NODE_OPTIONS=--max-old-space-size=8192 && npx @wakaru/cli unminify

8192 in the command is 8GB. You can adjust the number based on your PC's specs and the size of the file.

BTW, what is the size of your input file?

The file size is around 6-7mb. I'm trying the suggestion you said. How do we need to give the 8gb value you specified?

@0xdevalias
Copy link

0xdevalias commented Sep 27, 2024

How do we need to give the 8gb value you specified?

@Yusufkulcu I'm assuming you mean 'why do we need to specify 8gb if the file is only 6-7mb'? If so, it's because the process of unminimising the code needs to parse the plain text of the original file into a number of objects and data structures that are held and manipulated in memory, which causes it to expand to a much larger size during the process; and as the StackOverflow link I sent suggested, node has a default limit of only 1.7GB or similar.


I think the instructions are not step-by-step, so let me give one here.

@pionxzh Might be worth adding a section to the README with those instructions, and/or expanding them in the message shown in app (or maybe both/could link the in-app message to that part of the README for further details)

@pionxzh pionxzh added the enhancement New feature or request label Sep 27, 2024
@pionxzh
Copy link
Owner

pionxzh commented Sep 27, 2024

I will try to expand the instructions or link them to README to check the detailed guide.

@pionxzh
Copy link
Owner

pionxzh commented Sep 27, 2024

The file size is around 6-7mb. I'm trying the suggestion you said. How do we need to give the 8gb value you specified?

@Yusufkulcu I give the 8GB based on your mentioned "powerful PC." Based on my experience, 6-7 MB should only need ~4GB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scope: unminify
Projects
None yet
Development

No branches or pull requests

3 participants