18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Getting error "java.lang.OutOfMemoryError: Java heap space"

mituyadavmituyadav Members
edited August 2009 in Sahi - Open Source
I run the sahi.bat.
Then while trying to open the Firefox browser I am getting error.

>>>> Sahi started. Listening on port:9999
>>>> Configure your browser to use this server and port as its proxy
>>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Con
roller
Exception in thread "Thread-1365" java.lang.OutOfMemoryError: Java heap space

So this error is not letting the browser open since yesterday.
And even if the browser opens when the sahi.bat not running , the sahi interface controller is not running.
I have jdk1.5.0_06. How do I increase the heap size.

Please help me to solve it.

Thanks,
Mitu
Tagged:

Comments

  • narayannarayan Administrators
    Hi Mitu,

    Sahi generally uses very little memory. This error happens sometimes if you have configured the external proxy of Sahi to point to itself. Could you paste your sahi.properties file here?

    Btw, what is the RAM on your machine and do you run a lot of other applications which may lead to scarcity of memory?

    If you still want to increase the heapsize,

    Open sahi/bin/sahi.bat and change
    java -classpath %EXT_CLASS_PATH%;%SAHI_CLASS_PATH% net.sf.sahi.Proxy
    to
    java -Xms32m -Xmx128m -classpath %EXT_CLASS_PATH%;%SAHI_CLASS_PATH% net.sf.sahi.Proxy

    32 is the initial help size and 128 is the max heap size. Change it to whatever you want.

    Regards,
    Narayan
  • narayannarayan Administrators
    Mitu,

    Set
    ext.http.proxy.enable=false
    and
    ext.https.proxy.enable=false
    if you do not use an external proxy to access the internet.

    Is there are a reason why you set it to true?
    Do you generally use a proxy to access the internet?
    If yes, in sahi.properties, you have to set the host and port of YOUR proxy and not Sahi's proxy.

    Example:

    If you used to configure your browser to use myintranetproxy:808 to access any website on the internet (before using Sahi), you will have to set

    ext.http.proxy.host= myintranetproxy
    ext.http.proxy.port=808

    and

    ext.https.proxy.host= myintranetproxy
    ext.https.proxy.port=808

    in sahi.properties


    So, what was previously
    Browser -> myintranetproxy:808 (configured on browser) -> web site
    now becomes
    Browser -> localhost:9999 (Sahi proxy, now configured on browser) -> myintranetproxy:808 (external proxy, now configured in sahi.properties) -> web site

    Let me know if you still cannot get it working. You can also call me at 98809 65555, if needed.

    Regards,
    Narayan
    Mitu wrote:
    Narayan,
    Please find the Sahi.properties file content below.
    My system has 1GB ram. And not many process running currently.
    # Sahi configuration file
    proxy.port=9999
    # dirs. Relative paths are relative to bin dir. Separate directories with semi-colon
    scripts.dir=../scripts;
    script.extension=sah;sahi;inc
    # default log directory.
    logs.dir=../logs
    # Directory where auto generated ssl cerificates are stored
    certs.dir=../certs/
    # Use external proxy server for http
    ext.http.proxy.enable=true
    ext.http.proxy.host=localhost
    ext.http.proxy.port=9999
    ext.http.proxy.auth.enable=true
    ext.http.proxy.auth.name=mitu
    ext.http.proxy.auth.password=abcd@1111
    # Use external proxy server for https
    ext.https.proxy.enable=true
    ext.https.proxy.host=localhost
    ext.https.proxy.port=9999
    ext.https.proxy.auth.enable=true
    ext.https.proxy.auth.name=mitu
    ext.https.proxy.auth.password=abcd@1111
    # There is only one bypass list for both secure and insecure.
    ext.http.both.proxy.bypass_hosts=192.4.248.68|*.internaldomain.com|www.verisign.com

    # Sets the hotkey which when pressed and doubleclicked,
    # will open the Sahi controller window.
    # Can specify ALT, SHIFT, CTRL or META
    controller.hotkey = ALT
    # Time (in milliseconds) between tests. Increase this if you get random connection refused exceptions or if tests hang after some time. units milliseconds
    suite.time_between_tests=1000
    # Inactive time in SECONDS after which browser should be killed. Will happen if browser has hung or page load has been manually aborted.
    suite.max_inactive_time_for_script=60
    # set suite.global_variables to true if you want variables set via _setGlobal to be accessible across tests in a suite. Advisable to keep false.
    suite.global_variables=true
    # Script execution params
    #Time (in milliseconds) delay between steps
    script.time_between_steps=100
    #Time (in milliseconds) delay between retries once an error occurs
    script.time_between_steps_on_error=2000
    #Number of retries once an error occurs
    script.max_reattempts_on_error=5
    #Number of cycles Sahi will wait for the page to load before it proceeds with execution
    script.max_cycles_for_page_load=200
    #Time (in seconds) since last browser response, after which Sahi will terminate script with error
    script.max_idle_time=300
    # For automatic SSL keystore creation.
    ssl.auto_create_keystore=true
    ssl.password=sahipassword
    # Full file path to keytool utility if not in the system path
    # This is generally in the <java_home>/bin directory
    keytool.path=keytool
    http.keep_alive=true
    proxy.remote_socket_timeout=120000
    ff.profiles.template=../config/ff_profile_template
    ff.profiles.dir=../browser/ff/profiles
    ff.profiles.prefix=sahi
    ff.profiles.max_number=10
    response.modify_activex=true
    processhelper.pid_list_cmd=tasklist /FI "IMAGENAME eq $imageName" /NH /FO TABLE
    processhelper.pid_list_pid_column_no=2
    processhelper.pid_kill_cmd=taskkill /PID $pid
    #Use these for linux
    #processhelper.pid_list_cmd=ps -ef | grep $imageName
    #processhelper.pid_column_no=2
    #processhelper.pid_kill_cmd=kill -9 $pid
    debug.traffic.log = false
    # Set this to true if Sahi should not click or do other actions on
    # elements (like menu items) which are not visible
    element.visibility_check.strict = false
    # Set this to true if files should automatically be downloaded when the Content-disposition response header is "attachment"
    download.download_if_contentdisposition_is_attachment = false
    # Set this to false if browser seems to be idle for a long time due to AJAX calls.
    xhr.wait_when_ready_state_3 = true
    # This is the first n bytes of response data used to determine response type.
    # Change this to some other nearby value if you get "java.io.IOException: Resetting to invalid mark" errors on the console
    response.sample_length = 400
    Even after adding the line to sahi.bat to increase the heapsize , it is not working.
    Thanks,
    Mitu
  • Thanks Narayan for the instant help. Its working now for Mozilla.
    But I am not sure why it is not working for Internet explorer.The Sahi interface controller is not coming up.

    Could you please let me know.

    Thanks,
    Mitu
  • narayannarayan Administrators
    Mitu, have a look at these suggestions: http://sahi.co.in/w/help-the-sahi-controller-does-not-come-up
  • JohanJohan Members
    edited November 2010
    Sorry to drag this old issue up again - I'm having the exact same problem. First I set my heap space parameters so:
    -Xms128m -Xmx512m
    This made it take longer to throw the exception.
    Then I checked my sahi.properties, the external proxy had no settings, but both were set to enable=true. So I changed both to enable=false, restarted the proxy - this time it took a really long time when I started playback, but it still threw the exception.

    This was working fine all morning, then suddenly I got this the first time about an hour ago. I can't think of anything significant that changed that may have caused this...

    Now what?
  • I restarted my machine to see if that would help - no good.

    I tried using IE8 (was using firefox before) - IE seems to ignore my proxy settings, so the controller window can never come up. (When I turn off the proxy, IE is still able to browse the internet, no matter that the proxy config is set to use SAHI).
  • Ok, I figured it out. I had a script that includes a bunch of standard functions etc, then includes a specialized functions file.

    The specialized functions file also includes the same standard functions as the main script - so the standard stuff got included twice.

    So I removed the include statement from the functions file, now it's working.

    So this leads to a question: SAHI obviously concatenates all the scripts into one before executing - how big is this combined chunk of code allowed to get?
  • narayannarayan Administrators
    Hi Johan,

    I think, the OME would not be because of the number of scripts or duplication. Do you have a date.js library included? There was a recursion problem in an open source date library which arose when run in the rhino engine. You could try eliminating scripts one by one and figure which one is errant.

    Regards,
    Narayan
  • Hi Narayan

    Yes, we do use date.js - that is one of the "standard" includes that happened twice.

    Thank you!
    Johan
  • surimca09surimca09 Members
    edited October 2014
    Hi
    I also have the same issue.
    I tried what you mentioned above but the issue not resolved help me please
  • Hi
    I also have the same issue.
    I tried what you mentioned above but the issue noe resolved help me please
Sign In or Register to comment.