chrisnmorrison / revista-gatsby-blog-magazine

Modern, clean Gatsby Blog/Magazine template. Easy to customize, and ready to publish articles.
https://revista-gatsby-blog-magazine.pages.dev
MIT License
38 stars 30 forks source link

Possible memory leak #6

Closed bellons91 closed 1 year ago

bellons91 commented 1 year ago

Hi. I'm porting my blog to this theme.

There are around 130 articles, each with one cover image (well, actually there are some more, but I temporarily deleted them to try to fix this issue).

When compiling it, I used to see an error about heap allocation.

To solve it locally I had to increase the memory limit of the build process, updating the build command in the package.json file:

    "build": "cross-env NODE_OPTIONS=--max-old-space-size=16384 gatsby build --prefix-paths",
    "develop": "cross-env NODE_OPTIONS=--max-old-space-size=16384 gatsby develop",

Even with 16GB of memory, the build fails, as you can see from the logs here: https://app.netlify.com/sites/thriving-lolly-25f944/deploys/641ad5eedb761b02e5be526e

Any idea on what can cause the memory leak?

bellons91 commented 1 year ago

Here's the error message I receive on my local machine when I remove the cross-env NODE_OPTIONS=--max-old-space-size=16384 part

gatsby-plugin-purgecss:
 Previous CSS Size: 41.49 KB
 New CSS Size: 10.61 KB (-74.43%)
 Removed ~30.88 KB of CSS
⠏ Building HTML renderer
[======]    89.488 s51/5 100 Running gatsby-plugin-sharp.IMAGE_PROCESS…
 ==                 1    %

<--- Last few GCs --->

[10888:0000020E02EFA7A0]   190102 ms: Mark-sweep (reduce) 1880.3 (2076.6) -> 1880.2 (2068.6) MB, 757.4 / 0.0 ms  (average mu = 0.123, current mu = 0.032) allocation failure; GC in old space requested
[10888:0000020E02EFA7A0]   190914 ms: Mark-sweep (reduce) 1890.9 (2079.3) -> 1890.8 (2071.8) MB, 762.6 / 0.0 ms  (average mu = 0.093, current mu = 0.061) allocation failure; GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF74AAB2BCF node_api_throw_syntax_error+175519
 2: 00007FF74AA383A6 SSL_get_quiet_shutdown+64006
 3: 00007FF74AA39762 SSL_get_quiet_shutdown+69058
 4: 00007FF74B4DFDD4 v8::Isolate::ReportExternalAllocationLimitReached+116
 5: 00007FF74B4CB132 v8::Isolate::Exit+674
 6: 00007FF74B34CF8C v8::internal::EmbedderStackStateScope::ExplicitScopeForTesting+124
 7: 00007FF74B35A26D v8::internal::Heap::PublishPendingAllocations+1117
 8: 00007FF74B3572F7 v8::internal::Heap::PageFlagsAreConsistent+3367
 9: 00007FF74B349A27 v8::internal::Heap::CollectGarbage+2039
10: 00007FF74B3603E3 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath+2099
11: 00007FF74B360C8D v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath+93
12: 00007FF74B3695DA v8::internal::Factory::AllocateRaw+810
13: 00007FF74B37CA1D v8::internal::FactoryBase<v8::internal::Factory>::NewHeapNumber<0>+685
14: 00007FF74B380EC8 v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString+72
15: 00007FF74B128924 v8::internal::String::SlowFlatten+724
16: 00007FF74B4E99ED v8::String::Utf8Length+141
17: 00007FF74AA5E521 v8::internal::Malloced::operator delete+18209
18: 00007FF74B49895D v8::internal::Builtins::code+248237
19: 00007FF74B498569 v8::internal::Builtins::code+247225
20: 00007FF74B49882C v8::internal::Builtins::code+247932
21: 00007FF74B498690 v8::internal::Builtins::code+247520
22: 00007FF74B57D471 v8::internal::SetupIsolateDelegate::SetupHeap+558449
23: 00007FF6CD238CFA