Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
I was attempting to debug a growing memory leak in my application and think I know where it is. Currently, I use the beforeEach method to create one or more sequelize models and persist them to by DB. To ensure I can reference these models from each test, i do essentially the following:
After a while I noticed that none of these models were being garbage collected after running many tests.
In runner.js, each test is being pushed into the reporters array:
...And therefore holding on to all of the variables I created in my context until all tests have run. Since the flags given to each test is a clone, I can never nullify the content of my original test. So as each of my tests get pushed into the tests array above, memory usage grows.
I can't nullify that context in my afterEach hooks because I'm not getting the original context:
Perhaps context was not meant to be used for large objects such as data models, but I would think that once a test is run, it's context is no longer necessary. Unless I'm missing something, I'm happy to push a PR that nullifies the test's context once it's been run.
Let me know. Thanks!