如何解决因果报应的内存错误幻影 [英] How to get around memory error with karma & phantomjs
问题描述
我们正在使用karma
和phantomjs
进行测试,上周,我们的测试神秘地开始使phantomJS崩溃,错误为-1073741819.
We're running tests using karma
and phantomjs
Last week, our tests mysteriously started crashing phantomJS with an error of -1073741819.
基于Chutzpah
的该线程,似乎代码表明本地内存故障与PhantomJS.
Based on this thread for Chutzpah
it appears that code indicates a native memory failure with PhantomJS.
在进一步调查中,我们一直看到幻像崩溃大约有750MB的内存.
Upon further investigation, we are consistently seeing phantom crash around 750MB of memory.
是否有一种方法可以配置Karma,使其不会超出此限制?还是一种告诉它冲洗幻影的方法?
Is there a way to configure Karma so that it does not run up against this limit? Or a way to tell it to flush phantom?
到目前为止,我们只有大约1200个测试.我们大约在整个项目中进行了1/4的工作,因此似乎不可能进行5000次UI测试.
We only have around 1200 tests so far. We're about 1/4 of the way through our project, so 5000 UI tests doesn't seem out of the question.
推荐答案
由于发布问题并快速找到答案的StackOverflow现象,我们通过添加gulp
任务解决了这一问题.在我们仅在命令行上运行karma start
之前.这样就产生了一个phantomjs实例,该实例在达到750MB时崩溃了.
Thanks to the StackOverflow phenomenon of posting a question and quickly discovering an answer, we solved this by adding gulp
tasks. Before we were just running karma start
at the command line. This spun up a single instance of phantomjs that crashed when 750MB was reached.
现在,对于每个测试部分,我们都有一个gulp命令,例如gulp common-tests
和gulp admin-tests
和gulp customer-tests
Now we have a gulp command for each one of our sections of tests, e.g. gulp common-tests
and gulp admin-tests
and gulp customer-tests
然后使用一个gulp karma
运行这些分组中的每个分组.这样一来,每个gulp命令都可以拥有自己的幻像实例,因此可以保持在该阈值之下.
Then a single gulp karma
that runs each of those groupings. This allows each gulp command to have its own instance of phantom, and therefore stay underneath that threshold.
这篇关于如何解决因果报应的内存错误幻影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!