-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Array buffer allocation failed during ember test #873
Comments
Note: I opened an issue on the |
What version of Ember are you using? |
|
That error looks like glimmer-vm is attempting to create its heap (which it does via a typed array), and that is throwing an error. For context, here is the implementation of |
When does this error happen? Is it the first test, or somewhere in the middle of your 7k test suite? What is the memory consumed at the time the error happens? |
It occurs usually after around ~1500 tests have completed. How should I calculate the memory in order to show you? Something else worth noting, if I use |
I was thinking just using Chrome's |
Sure! It's also worth noting this error occurs either in the browser (via By the time the errors start to show up, I'm seeing ~900MB memory usage in the tab and it failed around test 1800. Some more data: We have 7385 tests, ~1000 integration tests, 10 application, and the rest unit. |
Turns out that the entire test suite runs just fine on Firefox. But I can confirm @justinzelinsky numbers. In latest Chrome it crashes right after 1800 tests have run at a memory allocation of ~900MB. |
Is the memory growing and eventually crashes at ~ 900, or is it fairly steady? |
The thing I'm trying to figure out here is if this error is happening due to a memory leak throughout the test suite... |
The memory is definitely growing and eventually crashes at ~900MB. Would a memory leak somewhere in the test suite also explain why Firefox has no issue running the entire suite? |
Firefox memory consumption maxes out at 50MB somewhere during the first 1000 tests (mostly application and rendering tests) and then drops just below 10MB for the rest of the suite (unit tests). |
Not sure to be honest. It doesn't obviously rule it out though (it's totally possible that FireFox will support more overall memory used by a tab before preventing it). What is the memory used by FireFox? Does it also continue to grow (even past the ~900MB level)? |
Haha, you beat me to the question! |
Is it as easy as saying if we had a memory leak it would leak in any browser? |
I'm just chiming in to confirm that we're also getting this on a ~10K tests suite, after upgrading from 3.4 to 3.24. I'll do the same memory analysis and reply back with some numbers. However, we get this when running with ember-exam. I'm going to try to run it straight in the browser without ember-exam to see if there's the same result. |
In the browser the error started appearing around 700MB of memory used by the tab, after it had been growing steadily. This was somewhere around 800-900 tests (I forgot to check, but I don't think it matters that much). I wanted to start the console to profile the tab, but it crashed after opening the tab. It definitely looks like a memory leak. I'll try doing a memory profile to see if I can pinpoint the root cause. |
Thanks for the details, much appreciated. I would love to know the answers to your questions :) |
(later edit to avoid spam) Here is a summary of all the scenarios I've ran and the results:
As you can see, Firefox has no issues running the suite, while Chrome is definitely limited by the memory, and splitting the test suite in enough partitions allows a single instance to finish running tests, but as we add more tests we might need to increase the split count. |
It looks very similar to something we had on a project having a lot of acceptance tests (800+), in the CI Chrome was going out of memory when running tests, in our case we were using sinonjs,, and in some of our tests we were not restoring stubs, leading to the app instance being kept, memory increase and crash. If your project use sinonjs, you may want to take a look to ember-sinon-qunit or to manually verify that each of your stub are restored at the end of each test (see sinonjs doc about this) Just made a test on our project, by commenting
If you are not using Could also helps to know if, before the update to latest version of Edit: in fact we have same issue on another app, using [email protected], if we use last version of ember-qunit it leads to memory growing (where with version 4.6.0 all's working fine) For example
|
@ndekeister-us tanks for your input, much appreciated. I'll most likely start to attack the memory issue by converting to |
We were getting this same issue after upgrading Ember from 3.16 to 3.24. In the same PR we also upgraded |
For us the situation was not resolved by downgrading. We were originally using v5.1.4 and [email protected]. However, after a test-helpers upgrade to 2.4.0 the memory snapshot retainers changed a bit, and they were no longer in I tried downgrading to 4.6.0, but the error is still popping out, with the memory used increasing steadily. Furthermore, trying to take a memory snapshot now crashes at all times, at a specific part of the recording process. There's probably some kind of reference that's crashing the tab/console. Having the same issue with the downgraded version as well makes me think it's most likely something on our end. We are not using Sinon, but testdouble, a similar library. While I'm sure we're properly tearing down the stubs, I'm not ruling out that there is something else in the our or the library code that's retaining this memory. |
TLDR: There seems to be an issue with WeakMaps in Chrome (starting with Long version: After some further investigation with v5.1.4, in our case it seems this is somehow related to WeakMaps in Chrome. This might be caused by slow GC, not necessarily a memory leak, but I'm not yet sure. The biggest retainer I've encountered is I added the following code in QUnit.testStart(function () {
enableDestroyableTracking();
assertDestroyablesDestroyed();
}); This effectively resets the After this change the tab no longer goes over 500MB of memory usage, but at some point I still start getting the allocation failed error. Some further analysis reveals that the I added the following code in const application = Application.create(config.APP);
QUnit.testDone(function () {
application._applicationInstances.forEach((appInstance) => {
appInstance.unregister('-top-level-view:main');
});
}); But unfortunately this is done too late, as at this point the instances array is already empty. Instead I wrote a wrapper for hooks.afterEach(function () {
this.owner.unregister('-top-level-view:main');
}); And this finally does the trick, but it is still a workaround, and doesn't explain or handle the underlying issue. My colleague @cristi-badila suggested to try an older Chrome version to run the suite (we tried I then started bisecting the versions (with 94 being the latest version) to figure out where the issue started occurring, as follows:
It is now pretty obvious that for our suite at least, the Chrome version makes the difference, and |
@monovertex thanks for sharing your findings in such great detail. It's very impressive and much appreciated. This seems to confirm our earlier inclination that this is a bug in Chrome since our test suite runs just fine in Firefox. |
Anyone made any further progress here? We are experiencing the same problem in Edge/Chrome. Unfortunately |
I recently updated
ember-qunit
to latest which also required me to installqunit
and@ember/test-helpers
manually. I noticed that when I would run my ~7000 unit tests that I would run into an error like this:To be honest, not sure where to go from here. Any advice would be appreciated.
The text was updated successfully, but these errors were encountered: