zstd-codec
zstd-codec copied to clipboard
javascript heap out of memory issue
I have install the zstc-codec in my react app and imported the module .But building the app gives below error
i have imported as below const ZstdCodec = require('zstd-codec').ZstdCodec; const simple = ZstdCodec.Simple();
<--- Last few GCs --->
[35284:000001D0E4A92950] 66095 ms: Mark-sweep 1361.4 (1441.8) -> 1361.4 (1418.8) MB, 1681.1 / 0.0 ms (average mu = 0.134, current mu = 0.000) last resort GC in old space requested [35284:000001D0E4A92950] 67728 ms: Mark-sweep 1361.4 (1418.8) -> 1361.4 (1418.8) MB, 1632.8 / 0.0 ms (average mu = 0.072, current mu = 0.000) last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 000001F9D105C5C1]
Security context: 0x03952a69e6e9 <JSObject>
1: _append [000000DBE659DED1] [C:\ReactApp-starter\react-userapp\node_modules@babel\generator\lib\buffer.js:~99] [pc=000001F9D1786219](this=0x030b0d786ab1 <Buffer map = 00000086883F31C9>,str=0x0004ca409d69 <String[1]: >,line=13,column=203215,identifierName=0x0004ca4022b1
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: 00007FF6543B81BA v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4506
2: 00007FF654392C56 node::MakeCallback+4534
3: 00007FF6543935D0 node_module_register+2032
4: 00007FF6546ABA9E v8::internal::FatalProcessOutOfMemory+846
5: 00007FF6546AB9CF v8::internal::FatalProcessOutOfMemory+639
6: 00007FF6548921C4 v8::internal::Heap::MaxHeapGrowingFactor+9620
7: 00007FF65489068B v8::internal::Heap::MaxHeapGrowingFactor+2651
8: 00007FF6549BA698 v8::internal::Factory::AllocateRawArray+56
9: 00007FF6549BB012 v8::internal::Factory::NewFixedArrayWithFiller+66
10: 00007FF6549E5256 v8::internal::Factory::NewCallHandlerInfo+113510
11: 00007FF654D37620 v8::internal::compiler::JSIntrinsicLowering::simplified+29264
12: 000001F9D105C5C1
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! [email protected] start:dev: cross-env REACT_APP_API_URL=http://localhost:3001 react-scripts start
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the [email protected] start:dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\212599043\AppData\Roaming\npm-cache_logs\2021-02-12T07_10_33_075Z-debug.log
ERROR: "start:dev" exited with 134.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: run-p start:dev start:api
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@ChauhanVinita Hello, did you solve this problem? I encounter the same error after install zstd-codec.
I'm also having this issue. In terms of repo-ing, i just did:
$ npx create-react-app myapp --template typescript
$ npm install zstd-codec
and at the top of my App.tsx
I added:
const ZstdCodec = require('zstd-codec').ZstdCodec;
which reliably causes the js heap OOM error to come up when running npm start
EDIT: Reproduced with v0.1.1 and v0.1.2. Maybe I'm using the package incorrectly?
EDIT2:
Just to clarify, this is my App.tsx
import React from 'react';
import logo from './logo.svg';
import './App.css';
const ZstdCodec = require('zstd-codec').ZstdCodec;
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
I've found a fix/work-around. I'm not really that familiar with web development, so not sure if this is the right thing to do, but if you make these changes in the package.json
:
"scripts": {
"start": "react-scripts --max_old_space_size=4096 start",
"build": "react-scripts --max_old_space_size=4096 build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Then it seems to work
Although now I run into a separate memory issue:
Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0
When running my actual app with streaming decompression