• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: React – Import big JSON file – Memory Error HEAP

Resolved: React – Import big JSON file – Memory Error HEAP

0
By Isaac Tonny on 15/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve React – Import big JSON file – Memory Error HEAP

Question:

Error: “FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of memory” error
I have a working react app with a relatively small footprint. However I want to import a JSON file in my React-App with lots of data. The file size is 80MB.
I import the file using: import MYJSON from ‘./myfile.json’
What I’ve tested is increasing my memory for the react app to 12GB.
“node –max-old-space-size=12000 node_modules/.bin/react-scripts start”
How can it be that an 80MB file raise the memory footprint of node from under 4GB to over 12GB with a single 80MB JSON file import and the app didn’t start or build?
Thanks for your help!

Best Answer:

80MB should not be a problem, but anyway you can try to open it using fs like a normal file and parse it to a Javascript object using JSON.parse.
Hope it helps.
Luis.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

allocation heap-memory javascript memory reactjs
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Input Focus between two React Components

02/04/2023

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Resolved: Table data is coming as empty in React

02/04/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.