无法分配内存 – RSelenium 和 EC2

huangapple go评论107阅读模式
英文:

cannot allocate memory - RSelenium and EC2

问题

I am trying to implement a Selenium test to perform automated actions on a website (looping through pages). I am using R and RSelenium package as well as a PostgreSQL database using DBI package. All this using EC2 AWS server.

My problem is that after a few minutes that the script was launched, my RStudio session freezes (as well as my Linux session) and I can see a message like "cannot allocate memory".
So this is clearly a memory issue without a doubt, and by doing top I could see that my Selenium docker was using most of the resources.

But my question is how can I reduce the amount of memory used by the Selenium test?

英文:

I am trying to implement a Selenium test to perform automated actions on a website (looping through pages). I am using R and RSelenium package as well as a PostgreSQL database using DBI package. All this using EC2 AWS server.

My problem is that after a few minutes that the script was launched, my RStudio session freezes (as well as my Linux session) and I can see a message like "cannot allocate memory".
So this is clearly a memory issue without a doubt, and by doing top I could see that my Selenium docker was using most of the resources.

But my question is how can I reduce the amount of memory used by the Selenium test?

答案1

得分: 1

不要忘记在你的代码中加入 drive.close(),如果你不关闭你的驱动程序,你将会有很多Chrome实例。

英文:

Don't forget drive.close() in your code, if you don't close your driver, you will have a lot instance of Chrome.

答案2

得分: 1

IMHO,对于测试来说,没有比给定测试所需内存更少的实际方式。您可以尝试将给定测试分解为2个或更多个测试来简化它。像另一个回答中建议的那样,检查内存泄漏。

如果节省资金是一个问题,使用下一个具有更多内存的实例类型并在不使用时关闭实例将更容易。

英文:

IMHO there is no practical way for a test to use less memory than the memory required by the given test. You can try to simplify the given test by breaking it up into 2 or more tests. Check for memory leaks, as suggested in another answer.

It would be much easier to use the next largest instance type with more memory, and shut down the instance when not in use to save money, if that is an issue.

huangapple
  • 本文由 发表于 2020年1月6日 22:55:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/59614252.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定