You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resulting string itself wouldn't cause to cause out of memory, it seems like process of serializing it does:
What I think is that JSON.stringify concatenate array items one by one and those intermediate strings are kept and we run out of memory before they are garbage collected (not sure about this, maybe someone with deeper v8 knowledge can correct me if I'm wrong).
This is change that fixes this problem (or maybe I should say workaround it) - pieh@b32ae20 (just don't pass nodes as-is to API hook) - but if we would have 2x more nodes - we would hit same problem when we serialize reducer state to save it to file - right now it seems we get out-of-memory crash because we serialize nodes array twice independently (in API runner tracing and redux state saving)
The text was updated successfully, but these errors were encountered:
Not passing allNodes is an easy win. Also serializing arguments to generate an ID is a problem... there should be a cheaper way to generate the id there. Even if it's just we include some specific ways to generate an ID for specific API calls that can be expensive like this one.
With sufficently large amount of data heavy nodes Gatsby v2 will fail with
JavaScript heap out of memory
(without increasing heap size).Terminal output
This seems to be cause by serializing huge nodes array to JSON string:
Here we pass all nodes and nodes of given type as args for
setFieldsOnGraphQLNodeType
API hook:gatsby/packages/gatsby/src/schema/build-node-types.js
Lines 145 to 153 in 917ca71
This later get's serialized (
JSON.stringify(args)
):gatsby/packages/gatsby/src/utils/api-runner-node.js
Lines 171 to 173 in 1194951
Resulting string itself wouldn't cause to cause out of memory, it seems like process of serializing it does:

What I think is that
JSON.stringify
concatenate array items one by one and those intermediate strings are kept and we run out of memory before they are garbage collected (not sure about this, maybe someone with deeper v8 knowledge can correct me if I'm wrong).This is change that fixes this problem (or maybe I should say workaround it) - pieh@b32ae20 (just don't pass nodes as-is to API hook) - but if we would have 2x more nodes - we would hit same problem when we serialize reducer state to save it to file - right now it seems we get out-of-memory crash because we serialize nodes array twice independently (in API runner tracing and redux state saving)
The text was updated successfully, but these errors were encountered: