question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak when using `--coverage`

See original GitHub issue

Do you want to request a feature or report a bug?

This is a bug report.

What is the current behavior?

I was able to isolate an example where adding the --coverage operation will cause a memory leak whereas the absence works just fine.

More specifically, the issue occurs when using a very large JavaScript file (in our case, it’s the asm.js artifact of PSPDFKit for Web. To work with JavaScript files of that size without issues, we have to add the file to the transformIgnorePatterns configuration option. As soon as we do this, the test passes as expected.

This was working fine in v22.2.2 and for the non- --coverage option, this still works fine.

However, when using the --coverage option, this test started to leak memory when we updated from v22.2.2 to v22.3.0. Hence I assume the exact time this started to cause issues is somewhere in this diff.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

I set up a repo that reproduces this behavior here.

What is the expected behavior?

yarn jest

and

yarn jest --coverage

Finishes in a reasonable time without causing the heap to explode.

Please provide your exact Jest configuration

https://github.com/PSPDFKit-labs/jest-leak/blob/master/package.json

Run npx envinfo --preset jest in your project directory and paste the results here

  System:
    OS: macOS High Sierra 10.13.1
    CPU: x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
  Binaries:
    Node: 9.7.1
    Yarn: 1.3.2
    npm: 5.6.0
  npmPackages:
    jest:
      wanted: ^22.4.2
      installed: 22.4.2

However, I was also able to reproduce this on other machines (e.g. our CI servers).

I also tried different versions of node without seeing a difference in this behavior.

Please let me know if I can provide further details for you.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:14
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
philipp-spiesscommented, Mar 20, 2018

I just found out about coveragePathIgnorePatterns and adding this will make the example pass. I still have no idea why this worked before though.

1reaction
SimenBcommented, May 4, 2018

@philipp-spiess We use babel to set up code coverage (babel-plugin-istanbul), which is why it runs even though you use transformIgnorePatterns, and the reason you need coveragePathIgnorePatterns.

@mnquintana a reproduction would be nice 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code coverage tools can cause unexpected Java Out of ...
Code coverage tools can cause unexpected Java Out of Memory errors · Too many classes loaded · Duplicate classes loaded · Large classes ......
Read more >
How To Detect and Prevent Memory Leaks | Scout APM Blog
Memory leak is the gradual loss of available computer memory when a program repeatedly fails to return memory it obtained for temporary use....
Read more >
Finding the cause of a memory leak in Jest tests
We've managed to fix the problem after a couple of hours, and we'd like to share the process of how we found the...
Read more >
Your Jest Tests are Leaking Memory
In this article, we'll walk through why it's so easy for Jest to leak memory, how to tell if your tests have a...
Read more >
Integration Testing for Memory Leaks - SoundCloud Developers
Memory leaks are a common problem when writing iOS applications, ... valuable amount of coverage with as few – short! it doesn't count...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found