Selenium: java.lang.OutOfMemoryError: Java heap space when run FF with profile

Created on 24 Oct 2016  路  6Comments  路  Source: SeleniumHQ/selenium

Meta -

OS: Win7
Selenium Version: 3.0.1
Browser: Firefox
Browser Version: 47.0.1

Expected Behavior -

Created new instance of webdriver

Actual Behavior -

There is no possibility to run firefox using profile.

java.lang.OutOfMemoryError: Java heap space

at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:137)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:121)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:421)
at java.lang.StringBuffer.append(StringBuffer.java:272)
at java.io.StringWriter.write(StringWriter.java:101)
at com.google.gson.stream.JsonWriter.string(JsonWriter.java:561)
at com.google.gson.stream.JsonWriter.value(JsonWriter.java:419)
at com.google.gson.internal.bind.TypeAdapters$25.write(TypeAdapters.java:690)
at com.google.gson.internal.bind.TypeAdapters$25.write(TypeAdapters.java:704)
at com.google.gson.internal.bind.TypeAdapters$25.write(TypeAdapters.java:704)
at com.google.gson.internal.bind.TypeAdapters$25.write(TypeAdapters.java:642)
at com.google.gson.internal.Streams.write(Streams.java:68)
at com.google.gson.Gson.toJson(Gson.java:668)
at com.google.gson.Gson.toJson(Gson.java:634)
at com.google.gson.Gson.toJson(Gson.java:619)
at org.openqa.selenium.remote.BeanToJsonConverter.convert(BeanToJsonConverter.java:67)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:54)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:467)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:259)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:135)
at com.ProfileTest.test(ProfileTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Steps to reproduce -

    DesiredCapabilities cap = DesiredCapabilities.firefox();
    cap.setCapability("marionette", false);
    cap.setCapability("firefox_profile", new ProfilesIni().getProfile("default"));

    FirefoxDriver driver = new FirefoxDriver(cap);
    driver.get("https://www.google.com/");

Most helpful comment

I reproduced this issue using 3.0.1 trying to run remotely with an 18MB local Firefox profile folder, on Mac OS X.

I specified various heap sizes, such as -Xmx1024m and -Xmx2056m and even -Xmx8192m, but the error persisted.

I fixed my problem by reducing the Firefox profile folder from 18MB to 13MB by deleting all sub-folders inside it and leaving all top-level files. The test now runs even with the default JVM heap settings.

Perhaps the issue is related to some particular sub-folders inside the profile directory itself.

All 6 comments

This is a java problem, not a selenium problem. Configure your JVM settings.

http://stackoverflow.com/questions/37335/how-to-deal-with-java-lang-outofmemoryerror-java-heap-space-error-64mb-heap

@lukeis I think problem is not in JVM settings. If I use selenium 2.53.1 - everything works as expected. I tried to run with settings -Xms512m -Xmx512m and got the same error.

Able to replicate the issue with following steps-

                DesiredCapabilities capabilities = DesiredCapabilities.firefox();

                ProfilesIni profile = new ProfilesIni();
                FirefoxProfile firefoxProfile = profile
                        .getProfile("default");
                capabilities.setCapability("marionette", false);
                capabilities.setCapability(FirefoxDriver.PROFILE,
                        firefoxProfile);

                driver = new FirefoxDriver(capabilities);

And trace as follows-

FAILED CONFIGURATION: @BeforeTest beforeTest
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:137)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:121)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:421)
at java.lang.StringBuilder.append(StringBuilder.java:136)
at org.openqa.selenium.remote.ProtocolHandshake.amendOssParamters(ProtocolHandshake.java:183)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:61)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:467)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:259)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:247)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:242)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:135)

Environment-
Win: 7
Webdriver:3.0.1
FF:46.0.1

I reproduced this issue using 3.0.1 trying to run remotely with an 18MB local Firefox profile folder, on Mac OS X.

I specified various heap sizes, such as -Xmx1024m and -Xmx2056m and even -Xmx8192m, but the error persisted.

I fixed my problem by reducing the Firefox profile folder from 18MB to 13MB by deleting all sub-folders inside it and leaving all top-level files. The test now runs even with the default JVM heap settings.

Perhaps the issue is related to some particular sub-folders inside the profile directory itself.

Hello everyone,

I can not find how to reduce Firefox profile folder

Best regards

Any updates yet? How to fix this. Iam getting this error in Chrome too.

Was this page helpful?
0 / 5 - 0 ratings