Description
It seems there are some problems with GC when rendering HTML. From the source code, vue-server-renderer
will parse the html on by one.
// render pages
logger.wait('Rendering static HTML...')
const pagePaths = []
for (const page of this.context.pages) {
pagePaths.push(await this.renderPage(page))
}
But actually the memory used will increase while rendering which is obviously the proof that there is something wrong with GC.
This issue is affecting me because my project is using more then 10 plugins, and that will take more memory in use and will take longer time rendering. So I can't build my project after my project grows rapidly by time.
In order not to here some reply like "Maybe there is something wrong with your plugin", I make a demo here with only two offical plugin: https://github.com/Mister-Hope/vuepress-stress-test
And here is the ci build log: https://travis-ci.com/github/Mister-Hope/vuepress-stress-test
<--- Last few GCs --->
[7024:0x4107550] 247201 ms: Mark-sweep 2036.3 (2053.1) -> 2035.3 (2053.1) MB, 2270.5 / 0.1 ms (average mu = 0.093, current mu = 0.007) allocation failure scavenge might not succeed
[7024:0x4107550] 249456 ms: Mark-sweep 2036.3 (2053.1) -> 2035.2 (2053.1) MB, 2253.1 / 0.0 ms (average mu = 0.049, current mu = 0.001) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x13a71b9]
1: StubFrame [pc: 0x13fcb5a]
Security context: 0x244948fc08d1 <JSObject>
2: get $page [0x25dc7d8d7301] [server-bundle.js:~29812] [pc=0x147f9e5102b6](this=0x3380cee64e39 <VueComponent map = 0x2aec759d8629>)
3: computedGetter [0x5771a6ef8d1] [/home/travis/build/Mister-Hope/vuepress-stress-test/node_modules/vue/dist/vue.runtime.common.dev.js:~4830] [pc=0x147f9e6b5cfe](this=0x3380cee64e39 <VueCompo...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Writing Node.js report to file: report.20200311.120332.7024.0.001.json
Node.js report completed
1: 0x9ef190 node::Abort() [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
2: 0x9f13b2 node::OnFatalError(char const*, char const*) [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
3: 0xb5da9e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
4: 0xb5de19 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
5: 0xd0a765 [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
6: 0xd0adf6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
7: 0xd1760a v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
8: 0xd18515 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
9: 0xd1afcc v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
10: 0xce19bb v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
11: 0x10246ce v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
12: 0x13a71b9 [/home/travis/.nvm/versions/node/v12.16.1/bin/node]
Aborted (core dumped)
error Command failed with exit code 134.
The doc folder is less than 10M in size, and more than a half of it's size are images. So I think that vuepress should have the ability to build it.
On windows 10, the demo I provided to you will use around 1200MB memory after building(before starting to render HTML). And it will sometimes build successlly, but it will always take more and more memory when rendering, and will reach 2GB in the end.
And, to make it more obviously, you can copy some files in the theme folder, you can use more plugins, you can add more files. That will all let the build process crush earilier.
P.S.: If you are testing it by adding more files, make sure their content are different, otherwise it won't have any effect because of cache-loader
.
I am opening this issue because as my acticles grows, I can no longer build my blog https://github.com/Mister-Hope/blog