3

我很惊讶,当我polymer build在实现更多组件后运行时,它会耗尽内存。这怎么可能?我不会认为我的网站/应用程序很大......

info:    Building application...
info:    Generating build/unbundled...
info:    Generating build/bundled...

<--- Last few GCs --->

  105411 ms: Mark-sweep 1343.6 (1434.7) -> 1343.0 (1434.7) MB, 1430.6 / 0 ms [allocation failure] [GC in old space requested].
  106857 ms: Mark-sweep 1343.0 (1434.7) -> 1343.0 (1434.7) MB, 1446.6 / 0 ms [allocation failure] [GC in old space requested].
  108349 ms: Mark-sweep 1343.0 (1434.7) -> 1343.0 (1434.7) MB, 1491.5 / 0 ms [last resort gc].
  109808 ms: Mark-sweep 1343.0 (1434.7) -> 1342.6 (1434.7) MB, 1459.5 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x24b44a0c9e31 <JS Object>
    2: nextToken [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/lib/node_modules/polymer-cli/node_modules/acorn/dist/acorn.js:~2459] [pc=0x313c0f47bb3b] (this=0x3618e7c0f981 <a Parser with map 0x18a29db9aa01>)
    3: next [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/lib/node_modules/polymer-cli/node_modules/acorn/dist/acorn.js:2413] [pc=0x313c0ee10d47] (this=0x3618e7c0f981 <a Parser with map 0x...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 4: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 5: v8::internal::FullCodeGenerator::PopulateDeoptimizationData(v8::internal::Handle<v8::internal::Code>) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 6: v8::internal::FullCodeGenerator::MakeCode(v8::internal::CompilationInfo*) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 7: v8::internal::Compiler::EnsureDeoptimizationSupport(v8::internal::CompilationInfo*) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 8: v8::internal::OptimizedCompileJob::CreateGraph() [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 9: v8::internal::Compiler::GetOptimizedCode(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ConcurrencyMode, v8::internal::BailoutId, v8::internal::JavaScriptFrame*) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
10: v8::internal::(anonymous namespace)::CompileOptimized(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ConcurrencyMode) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
11: v8::internal::Runtime_CompileOptimized_Concurrent(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
12: 0x313c0e50961b
13: 0x313c0e538279
[1]    8057 abort      polymer build

在详细模式下运行给了我一些线索:

debug:   accept: bower_components/iron-behaviors/iron-control-state.html
debug:   accept: bower_components/paper-ripple/paper-ripple.html
debug:   accept: bower_components/paper-styles/color.html
debug:   accept: bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html
debug:   accept: bower_components/iron-behaviors/iron-control-state.html
debug:   accept: bower_components/paper-ripple/paper-ripple.html
debug:   accept: bower_components/paper-styles/color.html
debug:   accept: bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html
debug:   accept: bower_components/iron-behaviors/iron-control-state.html
debug:   accept: bower_components/paper-ripple/paper-ripple.html
debug:   accept: bower_components/paper-styles/color.html
debug:   accept: bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html

似乎它在循环中运行?

更新

我注意到如果我从中删除一些组件polymer.json,它会构建,但它不是我真正想要的?

更新 2:可能的解决方法

不要碎片化一切。内联一些导入。认为它解决了这个问题,因为构建工具更有可能在“更大”的包中找到类似的依赖项,并能够将它们组合在一起。而不必将它们包含在所有捆绑包中。

4

1 回答 1

0

只是为了让我可以关闭它。

似乎问题在于创建了太多捆绑包。因此,我没有动态加载(几乎)每个单独的组件,我后来了解到这可能不是一个好主意,我开始将类似的东西组合在一起以包含在一个包中。这为我解决了这个问题。

于 2016-12-07T03:01:55.793 回答