Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential memory leak #3221

Open
amoore108 opened this issue Jul 23, 2024 · 3 comments
Open

Potential memory leak #3221

amoore108 opened this issue Jul 23, 2024 · 3 comments

Comments

@amoore108
Copy link

amoore108 commented Jul 23, 2024

Current behavior:
We're seeing a potential memory leak from the latest version of @emotion, possibly the @emotion/jest library specifically: https://github.com/bbc/simorgh/actions/runs/10039435131/job/27743362024?pr=11779

This behaviour can be reproduced locally by running this Dependabot update branch: bbc/simorgh#11779

I tried downgrading @emotion/jest back to 11.11.0 and it appears to work and not crash out (although causes snapshot issues, probably due to the mismatch between versions of expected packages)

Previously 11.12.0 of the other Emotion packages, apart from @emotion/jest, also worked: bbc/simorgh#11776

<--- Last few GCs --->

[2287:0x6fed8b0]   212859 ms: Mark-sweep (reduce) 2986.5 (3669.6) -> 2986.2 (3626.8) MB, 1090.5 / 0.0 ms  (average mu = 0.018, current mu = 0.001) last resort; GC in old space requested
[2287:0x6fed8b0]   214007 ms: Mark-sweep (reduce) 2986.2 (3626.8) -> 2986.1 (3615.6) MB, 1147.6 / 0.0 ms  (average mu = 0.009, current mu = 0.001) last resort; GC in old space requested


<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0xb9c1f0 node::Abort() [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
 2: 0xaa27ee  [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
 3: 0xd73950 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
 4: 0xd73cf7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
 5: 0xf3f18f v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
 6: 0xf1f158 v8::internal::Factory::CodeBuilder::AllocateCode(bool) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
 7: 0xf330cc v8::internal::Factory::CodeBuilder::BuildInternal(bool) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
 8: 0xf33b1e v8::internal::Factory::CodeBuilder::Build() [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
 9: 0x15ed38e v8::internal::RegExpMacroAssemblerX64::GetCode(v8::internal::Handle<v8::internal::String>) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
10: 0x12b1e86 v8::internal::RegExpCompiler::Assemble(v8::internal::Isolate*, v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handle<v8::internal::String>) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
11: 0x12d1db7 v8::internal::RegExpImpl::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::RegExpFlag, int>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, bool, unsigned int&) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
12: 0x12d2532 v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, bool) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
13: 0x12d30ee v8::internal::RegExpImpl::IrregexpPrepare(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
14: 0x12d3293 v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>, v8::internal::RegExp::ExecQuirks) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
15: 0x12f862e v8::internal::Runtime_RegExpExec(int, unsigned long*, v8::internal::Isolate*) [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]
16: 0x17120b9  [/opt/hostedtoolcache/node/18.20.4/x64/bin/node]

To reproduce:

  1. Pull down this branch locally: Bump the emotion group across 2 directories with 6 updates bbc/simorgh#11779
  2. Run yarn to install dependencies
  3. Run yarn test:unit to run unit tests
  4. Tests run for a period of time, but then crash out with a JavaScript heap out of memory error

Expected behavior:

  • Should run Jest tests and pass

Environment information:

  • react version: 18.3.1
  • @emotion/react version: 11.13.0
@Andarist
Copy link
Member

I can see what could cause this but I somewhat fail to see why 🤔 This shouldn't increase the memory usage all that much: 89bebfb

I can look into your issue given that you have provided the repro case... but it will take some days before I get to it.

@amoore108
Copy link
Author

Thanks @Andarist, no major rush on this. Appreciate your time looking into it 👍

@Nordicdesign
Copy link

Similar situation here, bumped @emotion/jest from 11.11.0 to 11.13.0 and now if I run my tests with --detectLeaks, they all fail as leaking memory. Going back to 11.11.0 solves it.

Unfortunately can't provide a small repo to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants