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

JavaScript heap out of memory #55

Closed
xehpuk opened this issue Mar 27, 2018 · 6 comments · Fixed by #84
Closed

JavaScript heap out of memory #55

xehpuk opened this issue Mar 27, 2018 · 6 comments · Fixed by #84

Comments

@xehpuk
Copy link

xehpuk commented Mar 27, 2018

I have a file with the line const cldr = require('cldr-data'). When importing the file, Node eats more and more RAM until…

$ webpack-dev-server --config webpack.config.js -d --watch

<--- Last few GCs --->

[15088:0000015D8C7B99E0]   157944 ms: Mark-sweep 1245.7 (1583.9) -> 1245.5 (1585.4) MB, 462.8 / 0.0 ms  allocation failure GC in old space requested
[15088:0000015D8C7B99E0]   158428 ms: Mark-sweep 1245.5 (1585.4) -> 1244.5 (1536.9) MB, 483.7 / 0.0 ms  last resort GC in old space requested
[15088:0000015D8C7B99E0]   158913 ms: Mark-sweep 1244.5 (1536.9) -> 1244.5 (1521.9) MB, 484.6 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 000003FD2EBA5529 <JSObject>
	0: builtin exit frame: stringify(this=000003FD2EB88D59 <Object map = 0000037CAA182BA1>,000000EAF32822D1 <undefined>,000000EAF32822D1 <undefined>,000001DE350DC281 <Very long string[469998]>)

	1: arguments adaptor frame: 1->3
	2: /* anonymous */ [...\node_modules\webpack\lib\EvalSourceMapDevToolModuleTemplatePlugin.js:66] [bytecode=0000030ED3173019 ...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::DecodeWrite
 2: node_module_register
 3: v8::internal::FatalProcessOutOfMemory
 4: v8::internal::FatalProcessOutOfMemory
 5: v8::internal::Factory::NewRawTwoByteString
 6: v8::internal::Smi::SmiPrint
 7: v8::internal::StackGuard::HandleInterrupts
 8: v8::internal::wasm::LocalDeclEncoder::Size
 9: v8::internal::wasm::LocalDeclEncoder::Size
10: v8_inspector::protocol::Debugger::API::SearchMatch::fromJSONString
11: v8_inspector::protocol::Debugger::API::SearchMatch::fromJSONString
12: 0000012CCAD86B21
error An unexpected error occurred: "Command failed.
Exit code: 134

What's wrong here?

@rxaviers
Copy link
Owner

Please, can you share in a gist a minimum way to reproducible the issue you see?

@Usnul
Copy link

Usnul commented Jun 26, 2018

related angular/angular-cli#5618

@rxaviers
Copy link
Owner

require('cldr-data') can't be used with webpack because when it sees dynamic imports, webpack simply includes everything.

It works including things explicitly such as import enNumbers from "cldr-data/main/en/numbers.json" (tedious). A better alternative is using plugins such as globalize webpack plugin (if using globalize).

We need to update README.md to reflect this. Do you want to help?

@ConorSheehan1
Copy link

require('cldr-data') can't be used with webpack because when it sees dynamic imports, webpack simply includes everything.

It works including things explicitly such as import enNumbers from "cldr-data/main/en/numbers.json" (tedious). A better alternative is using plugins such as globalize webpack plugin (if using globalize).

We need to update README.md to reflect this. Do you want to help?

Using the import syntax stops the heap overflow, but it still doesn't compile for me.

ERROR in ./node_modules/globalize/dist/globalize/number.js
Module not found: Error: Can't resolve 'cldr/supplemental' in '/Users/me/Workspace/my_app/node_modules/globalize/dist/globalize'
 @ ./node_modules/globalize/dist/globalize/number.js 22:2-27:14
 @ ./node_modules/globalize/dist/node-main.js
 @ ./client/js/filters/compactNumber.js
 @ ./client/js/filters \.js$
 @ ./client/app.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:9000 webpack/hot/dev-server babel-polyfill ./client/app.js

I'm trying to use Globalize.numberFormatter. Here's what I'm trying to load:

let Globalize = require('globalize');
// minimum required cldr-data to use Globalize.numberFormatter({ compact: 'short', maximumFractionDigits: 0 })
// generated by http://johnnyreilly.github.io/globalize-so-what-cha-want/#/?currency=false&date=false&message=false&number=true&plural=false&relativeTime=false&unit=false
import enNumbers from 'cldr-data/main/en/numbers.json';
import likelySubtags from 'cldr-data/supplemental/likelySubtags.json';
import numbers from 'cldr-data/supplemental/numberingSystems.json';
Globalize.load(enNumbers);
Globalize.load(likelySubtags);
Globalize.load(numbers);

@heyakyra
Copy link

heyakyra commented Mar 7, 2022

A better alternative is using plugins such as globalize webpack plugin (if using globalize)

This seems unmaintained. Trying to install causes conflicts for me because it's webpack dependency is too old

@MehmetYararVX
Copy link
Contributor

MehmetYararVX commented Apr 10, 2024

Similar error caused by the inflight package: isaacs/inflight-DEPRECATED-DO-NOT-USE#5

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

Successfully merging a pull request may close this issue.

6 participants