Selenium using too much memory - java

I'm using selenium on python 3.5 with chrome webdriver on a ububtu vps, and when I run a very basic script (navigate to site, enter login fields, click), memory usage goes up by ~400mb,and cpu usage goes up to 100%. Are there any things I can do to lower this, or if not, are there any alternatives?
I'm testing out selenium in python but I plan to do a project with it in java, where memory usage is a critical factor for me, so the same question applies for java as well.

I believe your memory usage problem is caused by selenium. AFAIK it runs on webkit, which is also used by Googles Chrome browser. And chrome is well known for it's excessive memory usage.
This might help:
Selenium github issue #4988

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

This should not happen I believe unless there is a leak.
Please try install nmon on your machine and run the test.
Nmon
This would help in figuring out exact cause of high CPU utilization and resolve your issue.

Related

Debugging memory leak issues in a Java app

I'm very new to Java. I'd like to help one of our teams that is working on an internal bank application. I'm one of the server support that has access to Windows and Linux servers. Anyways, the java app is running on linux. What tools would be appropriate for capturing memory leaks that can help pinpoint which code block is actually making the memory leak? Found few tools like jstat and jmap. Are these good? Is this safe to run in production? Or how would you debug an issue where cpu goes to 100%?

How to stop stuck jmeter executed in GUI mode

When I run Jmeter java swing application in GUI mode and it got stuck (GUI not responding),
How can I stop/shutodown it without kill the process?
When UI is stuck, it's too late to do anything. You can try to cause a full GC, but your chances to even improve the situation are low: it won't help if OOM already happened, or if full GC was already triggered by JVM, but did not help.
And even if it helps, likely the improvement will be temporary (it may be enough just to stop test properly, rather than abruptly). And continuing test after that state is not a good idea, since the results will be unreliable.
A better idea is to prevent JMeter from getting into that state:
Follow Best Practices (specifically Reducing resource requirements paragraph)
Make sure you provided Java running JMeter with adequate memory settings. See this discussion for more details on memory parameters.
Make sure machine itself has enough memory.
If it's a VM, make sure you are not over-committing physical memory on a host.
I am not aware of any way to "unfreeze" a hung test, most probably you have ruined it and there are no recovery options. You could try waiting for the test to finish if your JVM is not completely dead, but depending on your configuration it may take hours or even days (we need to see your thread dump in order to be able to suggest anything)
In general JMeter GUI is designed for tests development and debugging only as it evidenced by this warning which is displayed on every launch of JMeter:
So going forward please run JMeter in command-line non-GUI mode when it comes to executing a load test. Also it worth sticking to recommendations from the 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure, this way you will be able to tune JMeter for maximum performance.

JxBrowser takes huge RAM

I am using jxbrowser to make an automation test application.
After run a lot of automation tests(login to a webpage, click some button, perform some UI interaction), I reallize that the jxbroser-chromium.exe took so huge RAM, Even after doing some automation tests, I load "about:blank" page
Note that I use only one instance of Browser & BrowserView
Is there any way to clean & clear RAM when using jxbrowser?
JxBrowser is based on Chromium engine. Chromium engine is running in the jxbrowser-chromium.exe process. JxBrowser doesn't control the memory in this process. All memory management is done by Chromium engine. If you see that the process allocates too much memory, then it means that Chromium engine decided to allocate this amount of memory for some reasons.
I believe if you do the same automated tests in Google Chrome tab, you will see the same memory usage issue. As far as I know there's no Chromium API that would clear the memory of an existing tab/browser. To clear the memory I can only suggest that you dispose Browser instance and create it again.

Terribly slow on Grails app

The performance of grails app is terribly slow. It needs at least 5-7 seconds to load a page. Sometimes will prompt me OutOfMemory and then server error 500 for every page.
The terribly slow performance seriously affects my work and I am unable to test and develop the project in an acceptable time. I have to deal with this problem first.
I tried to:
Config the settings in idea64.exe.vmoptions and idea.exe.vmoptions like the settings in development handbook.
Config the settings of Java in Java Control Panel that I added a Runtime Parameters –Xms-4096m.
Config the settings of %GRAILS_HOME%\bin\startGrails.bat, GRAILS_OPTS.
However, this situation is not improveing.
I am using Win7-64 bit, 8GB Ram, Intellij 13.0.2 to develop.
Please help. Thank you very much!!
This is likely to be an issue with your database lookup.
Out of memory errors are probably caused by bringing back too much data (possibly filtering in the JVM instead of the database query).
Slowness is possibly caused again by bringing back too much data, or by n+1 selects
Thank you for #Houcem Berrayana answer:
Try to increase memory by using GRAILS_OPTS env variable
I just add the environment variable GRAILS_OPTS with parameter -Xms4096, then the Grails app run so fast!!
Thank you again!

Getting JVM error after SOAP UI installation

I am trying to install SOAPUI tool. After the installation, when executed, I amm getting this error:
The JVM could not be started. The maximum heap size (-XMx) might be
too large or anti virus or firewall tool could block the execution
When installed to a different machine, it works fine.
Any suggestions?
This problem occurs because Soap Ui tries to get the specified amount of memory in form of single block which is rarely available.
So solution to this problem is navigate to soapUi.x.x.x.vmoption file which can be found in
c->program files-> emiware -> soapUi.x.x.x ->bin
edit this file and make the -Xms to something lesser default value is 1200m make it 512m if does not work change it some to a lesser value.
PS x.x.x. is the version of SoapUI in my case its 4.0.0
-Xms means initial heap size.
-Xmx means maximum heap size.
So you can set values as per your requirement.
This error often occurs if you try to set too much memory on a 32-bit OS such as Windows. E.g. if you use -Xmx1600m or more on Windows 32-bit you will get this error.
Which OS and version of Java do you have on the machine which fails.
What I did with mine is kill all application processes that use Java, for example: Mozilla FireFox. You can kill the process from Windows Task Manager. After that, rerun your SOAP UI.
There is quite a simple fix to this soapUI issue...
Ankit and Peter have mentioned about it here... to help you (and others) with this, I have written a step-by-step tutorial for this along with screenshots for the fix. I hope this helps you...!
You can check it here - http://quicksoftwaretesting.com/soapui-jvm-heap-size-xmx-error/
Neither of these solutions worked for me. What did work was starting the soapui.bat file int he same mentioned \bin directory.
This file does set the required JAVA environment settings.
Using Java a lot I cannot do this as an general Environment variable since this will impact my SQLdeveloper from Oracle and other Java goodies.
Make sure you downloaded the appropriate version (32/64 bit) for your OS.

Categories