mui / pigment-css

Pigment CSS is a zero-runtime CSS-in-JS library that extracts the colocated styles to their own CSS files at build time.
MIT License
826 stars 39 forks source link

[next] Memory leak in pigment >=0.0.26 #328

Open axeleroy opened 4 days ago

axeleroy commented 4 days ago

After upgrading to 0.0.26, next-server would not finish any compilation while its memory footprint would keep growing at a rate of 4GB/min, quickly filling up the RAM.

Downgrading to 0.0.25, the compilation completes while using a little over 6GB and upgrading to 0.0.27 yields the same result.

The issue now (with 0.0.27) is that our CI crashes with an OOM error while building our front-end:

> next build
  ▲ Next.js 14.2.15
  - Environments: .env
   Creating an optimized production build ...
<--- Last few GCs --->
[2743:0x5aa1050]    61835 ms: Scavenge (reduce) 1851.7 (2082.3) -> 1851.4 (2082.6) MB, 4.11 / 0.00 ms  (average mu = 0.127, current mu = 0.060) allocation failure; 
[2743:0x5aa1050]    61850 ms: Scavenge (reduce) 1852.4 (2082.8) -> 1851.9 (2083.3) MB, 3.46 / 0.01 ms  (average mu = 0.127, current mu = 0.060) allocation failure; 
[2743:0x5aa1050]    61870 ms: Scavenge (reduce) 1852.9 (2083.3) -> 1852.2 (2083.6) MB, 16.62 / 0.00 ms  (average mu = 0.127, current mu = 0.060) allocation failure; 
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----
 1: 0xb8ced1 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
 2: 0xf06460 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 3: 0xf06747 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0x11182e5  [node]
 5: 0x1118874 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 6: 0x112f764 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
 7: 0x112ff7c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 8: 0x1106281 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 9: 0x1107415 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0x10e4a66 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
11: 0x1540896 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x7f6697e99ef6 
Aborted (core dumped)
 ELIFECYCLE  Command failed with exit code 134.
Error:  command finished with error: command (/home/runner/work/next-mono/next-mono/apps/front) /home/runner/setup-pnpm/node_modules/.bin/pnpm run build exited (134)

Your environment

npx @mui/envinfo ``` System: OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat) Binaries: Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm pnpm: 8.15.9 - ~/.nvm/versions/node/v20.18.0/bin/pnpm Browsers: Chrome: Not Found npmPackages: @pigment-css/nextjs-plugin: ^0.0.27 => 0.0.27 @pigment-css/react: ^0.0.27 => 0.0.27 @types/react: 18.3.12 => 18.3.12 next: 14.2.15 => 14.2.15 react: 18.3.1 => 18.3.1 react-dom: 18.3.1 => 18.3.1 ```

Search keywords: