uncss: JavaScript heap out of memory

Running out of heap memory, when a lot of files are processed. When I process files in chunks, they work. But that adds duplicate css to output. Is there any workaround, or do I need to increase my RAM?

<--- Last few GCs --->

  281562 ms: Mark-sweep 1318.5 (1435.8) -> 1318.5 (1435.8) MB, 933.2 / 0.0 ms [allocation failure] [GC in old space requested].
  282492 ms: Mark-sweep 1318.5 (1435.8) -> 1318.5 (1435.8) MB, 930.2 / 0.0 ms [allocation failure] [GC in old space requested].
  283424 ms: Mark-sweep 1318.5 (1435.8) -> 1319.1 (1411.8) MB, 931.4 / 0.0 ms [last resort gc].
  284359 ms: Mark-sweep 1319.1 (1411.8) -> 1319.1 (1411.8) MB, 934.8 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

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

Security context: 000002C3FB43FA99 <JS Object>
    1: filter(aka filter) [C:\CoC_Front\node_modules\jsdom\lib\jsdom\living\node.js:95] [pc=0000025875688B79] (this=000002C3FB404241 <undefined>,node=000003837F0B6761 <an EventTargetImpl with map 0000009474E48B41>)
    2: treeToArray [C:\CoC_Front\node_modules\symbol-tree\lib\SymbolTree.js:~338] [pc=0000025874F8AAEF] (this=000003010D982BF9 <a SymbolTree with map 00000182CC9544E1>,root=0000006...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

I was able to crash uncss by running it against a huge list of URLs (I was using the JS API). I think this is basically an inherent limitation of how Node and UnCSS works. UnCSS basically loads all the pages, then all the CSS, and then begins its work.

Node can’t use all your system RAM, the heap is capped at a certain size. My task manager showed over 1.6 GB of memory usage before Node crashed. Edit: It can’t use more than 1.7 GB.