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.

serious problem in sahi

beesmanbeesman Members
edited August 2010 in Sahi - Open Source
when you start the sahi and open the ie browser,

open the task manager
u will find the memory of the thread iexplore.exe incerase until your pc memory out

Comments

  • narayannarayan Administrators
    Hi Beesman,

    Sahi is being used on IE for a few years now by various organizations. So this bug has to be something very specific to your web application + Sahi or your configuration. Could you please give us more information?

    Regards,
    Narayan
  • beesmanbeesman Members
    edited July 2010
    Hi Narayan
    I tried the following:
    browser os memory
    IE7 XP incerase
    IE8 XP incerase
    IE8 win7 incerase
    FF3.5 xp incerase and DECREASE normal


    version Sahi 2010-06-10
  • Hi,

    I have also observed a similar behavior while using the older(non-rhino) version. The behavior is expected as the test script was also loaded with every page load/refresh. So it consumes some memory but the consumption has hardly gone to alarming levels. Try to break down the script and run in a suite if the script size is too large. Also check if the script goes into deeply nested loops or even endless loops.

    Regards,
    Pankaj Kumar
  • beesmanbeesman Members
    hi
    I tried the latest version of sahi.

    I just start sahi and set the proxy and access www.google.com only
    then start the window task manager , observe the iexploer.exe thread.

    i haven't run anny thing!!!!
  • narayannarayan Administrators
    Hi Beesman,

    We will look into this. Currently, does this affect your automation adversely?

    Regards,
    Narayan
  • beesmanbeesman Members
    hi narayan
    I having test my project, until the usage of memory up to 4G, I have to close IE
    and restart the ie.

    out of memory is realy slow my pc.

    when i test ,i USE FF, not IE there is no affact.
  • beesmanbeesman Members
    edited August 2010
    today , i keep the sahi running and to go to have a meeting , after the meeting the volumn of memory (iexplore.exe ) up to 3G, and the window show a wanning message ,out of memory.
  • pankaj.nithpankaj.nith Members
    edited August 2010
    Hi,

    Use StackTrace utility to get a stack trace and try to figure out if there is any particular process/thread that is causing the memory problem. Try to see if something is causing an endless loop. You can get the utility at:
    http://www.adaptj.com/main/stacktrace
    Another thing you can try is get the latest JRE that is compatible with your IE.

    Regards,
    Pankaj
  • narayannarayan Administrators
    Hi Beesman,

    There was a bug and it has been fixed now.
    Would you like to get a build where you can check and let us know if it works?

    Regards,
    Narayan
  • beesmanbeesman Members
    edited August 2010
    Hi narayan

    There is no memory leak in version 20100806.
    but

    problem1
    2010/08/09 10:29:43 net.sf.sahi.RemoteRequestProcessor processHttp
    warnning: java.lang.NullPointerException
            at java.lang.String.<init>(Unknown Source)
            at net.sf.sahi.response.HttpModifiedResponse2.<init>(HttpModifiedRespons
    e2.java:50)
            at net.sf.sahi.RemoteRequestProcessor.addFilters(RemoteRequestProcessor.
    java:246)
            at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
    .java:203)
            at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
    .java:81)
            at net.sf.sahi.ProxyProcessor.processAsProxy(ProxyProcessor.java:142)
            at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:93)
            at java.lang.Thread.run(Unknown Source)
    
    
  • beesmanbeesman Members
    edited August 2010
    problem 2 only in version 0806

    see
    http://sahi.co.in/forums/viewtopic.php?id=1746
  • narayannarayan Administrators
    Hi Beesman,

    Thanks for the update.

    Could you specify when you get problem 1?

    I could not understand: " if there is a lot check of submit event"? Could you please explain that?

    Thanks,
    Narayan
  • beesmanbeesman Members
    edited August 2010
    i modified HttpModifiedResponse2.java
    HttpModifiedResponse2.java
        public HttpModifiedResponse2(final HttpResponse response, final boolean isSSL, String fileExtension, int responseCode) {
            this.fileExtension = fileExtension;
            copyFrom(response);
            /*
            removing cache headers again for login problem.
            test on IE sahi.co.in login/logout
            */
            this.isSSL = isSSL;
            if (responseCode < 300 || responseCode >= 400) { // Response code other than 3xx
                boolean html = isHTML();
                boolean js = isJs();
                if (html || js){
                    charset(); // set it
                    try {
                        System.out.println((new Date()) + "HttpModifiedResponse2#data():" + data() + charset);
                        dataString = new String(data(), charset);
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                        dataString = new String(data());
                    }
                    if (html) {
                        HTMLModifierFilter htmlModifierFilter = new HTMLModifierFilter(charset, isXHTML(), isSSL);
                        htmlModifierFilter.modifyHeaders(response);
                        dataString = htmlModifierFilter.modify(dataString);
                    }
                    JSModifierFilter jsModifierFilter = new JSModifierFilter(charset);
                    dataString = jsModifierFilter.modify(dataString);
                    
                    try {
                        setData(dataString.getBytes(charset));
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                    }
                    if (html) {
                        new NoCacheFilter().modifyHeaders(response);
                    }
                }
            }
        }
    
    


    http://mypc/baby.do
    sahi console
    os:xp
    Tue Aug 10 18:11:18 JST 2010HttpModifiedResponse2#data():[B@19dfbffwindows-31j
    Tue Aug 10 18:11:19 JST 2010HttpModifiedResponse2#data():[B@913fe2Windows-31J
    Tue Aug 10 18:11:20 JST 2010HttpModifiedResponse2#data():[B@12a54f9Shift_JIS
    Tue Aug 10 18:11:20 JST 2010HttpModifiedResponse2#data():[B@16672d6Windows-31J
    Tue Aug 10 18:11:20 JST 2010HttpModifiedResponse2#data():[B@26d4f1Shift_JIS
    Tue Aug 10 18:11:20 JST 2010HttpModifiedResponse2#data():[B@147c5fcWindows-31J
    Tue Aug 10 18:11:20 JST 2010HttpModifiedResponse2#data():[B@3eca90Windows-31J
    Tue Aug 10 18:11:20 JST 2010HttpModifiedResponse2#data():[B@4413eeShift_JIS
    

    http://remotepc/baby.do
    os:solarix
    sahi console
    Tue Aug 10 18:11:42 JST 2010HttpModifiedResponse2#data():[B@15ee671windows-31j
    Tue Aug 10 18:11:42 JST 2010HttpModifiedResponse2#data():[B@12d7a10Windows-31J
    Tue Aug 10 18:11:43 JST 2010HttpModifiedResponse2#data():nullShift_JIS
    2010/08/10 18:11:43 net.sf.sahi.RemoteRequestProcessor processHttp
    Warnning: java.lang.NullPointerException
            at java.lang.String.<init>(Unknown Source)
            at net.sf.sahi.response.HttpModifiedResponse2.<init>(HttpModifiedRespons
    e2.java:52)
            at net.sf.sahi.RemoteRequestProcessor.addFilters(RemoteRequestProcessor.
    java:246)
            at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
    .java:203)
            at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
    .java:81)
            at net.sf.sahi.ProxyProcessor.processAsProxy(ProxyProcessor.java:142)
            at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:93)
            at java.lang.Thread.run(Unknown Source)
    
    
  • beesmanbeesman Members
    edited August 2010
    HttpResponse.java
        public HttpResponse(InputStream in, HttpURLConnection connection) {
            setHeaders(connection);
            setFirstLine(connection);
            setContentLength(-1);   
            try{
                populateData(in);
            }catch(IOException ioe){
                System.out.println("HttpResponse():" + ioe);
                // suppress;
            }
        }
    
    

    when i access solarix server ,and charset is changed the exception occurs.
    this cause the data() is null


    console
    HttpResponse():java.io.IOException: Stream closed
    null
    2010/08/12 8:52:47 net.sf.sahi.RemoteRequestProcessor processHttp
    Warnning: java.lang.NullPointerException
            at java.lang.String.<init>(Unknown Source)
            at net.sf.sahi.response.HttpModifiedResponse2.<init>(HttpModifiedRespons
    e2.java:58)
            at net.sf.sahi.RemoteRequestProcessor.addFilters(RemoteRequestProcessor.
    java:250)
            at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
    .java:207)
            at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
    .java:81)
            at net.sf.sahi.ProxyProcessor.processAsProxy(ProxyProcessor.java:142)
            at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:93)
            at java.lang.Thread.run(Unknown Source)
    


    summary

    when access solarix server and page encoding Window3j->Shift_jis exception occurs in populateData(in)
    and then HttpModifiedResponse2#data() is null
    when access windows server and encoding Window3j->Shift_jis exception not occurs in populateData(in)
    and then HttpModifiedResponse2#data() is empty string
  • beesmanbeesman Members
    edited August 2010
    java.io.IOException: Stream closed
            at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
            at java.io.BufferedInputStream.read1(Unknown Source)
            at java.io.BufferedInputStream.read(Unknown Source)
            at java.io.FilterInputStream.read(Unknown Source)
            at net.sf.sahi.util.Utils.getBytes(Utils.java:84)
            at net.sf.sahi.StreamHandler.populateData(StreamHandler.java:39)
            at net.sf.sahi.response.HttpResponse.<init>(HttpResponse.java:52)
            at net.sf.sahi.RemoteRequestProcessor.getResponse(RemoteRequestProcessor
    .java:227)
            at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
    .java:157)
            at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
    .java:81)
            at net.sf.sahi.ProxyProcessor.processAsProxy(ProxyProcessor.java:142)
            at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:93)
            at java.lang.Thread.run(Unknown Source)
    
    Utils.java
        public static byte[] getBytes(final InputStream in, final int contentLength) throws IOException {
            BufferedInputStream bin = new BufferedInputStream(in, BUFFER_SIZE);
    
            if (contentLength != -1) {
                .......
            } else {
                ByteArrayOutputStream byteArOut = new ByteArrayOutputStream();
                BufferedOutputStream bout = new BufferedOutputStream(byteArOut);
                try {
                    int totalBytesRead = 0;
                    byte[] buffer = new byte[BUFFER_SIZE];
    
                    while (true) {
    //Exception occurs here
                        int bytesRead = bin.read(buffer);
                        if (bytesRead == -1) {
                            break;
                        }
                        bout.write(buffer, 0, bytesRead);
                        totalBytesRead += bytesRead;
                    }
                } catch (SocketTimeoutException ste) {
                    ste.printStackTrace();
                }
                bout.flush();
                bout.close();
                return byteArOut.toByteArray();
            }
        }
    
    
  • beesmanbeesman Members
    edited August 2010
    I solved this problem
    HttpModifiedResponse2.java
        public HttpModifiedResponse2(final HttpResponse response, final boolean isSSL, String fileExtension, int responseCode) {
                   ..................
                    charset(); // set it
                    try {
    //here what i added
                        if(data() == null){
                            dataString = "";
                        }else{
                            dataString = new String(data(), charset);
                        }
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                        dataString = new String(data());
                    }
                    ................
        }
        String getSampleContent(String charset) {
            String sampleContent = null;
            try {
                int limit = Configuration.sampleLength();
                if (contentLength() < limit) limit = contentLength();
    //here what i added
                if(data() == null){
                    sampleContent = "";
                }else{
                    sampleContent = new String(data(), 0, limit, charset).toLowerCase();                
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            return sampleContent;
        }
    
    
  • narayannarayan Administrators
    Nice work Beesman! Thanks a lot for your contributions! Your fix is right. It needed null checks in those two places.

    Thanks and regards,
    Narayan
  • when run sahi script the ie memory leak occurs again.
Sign In or Register to comment.