[jbossseam-issues] [JBoss JIRA] Updated: (JBSEAM-3225) Seam Remoting JS memory leak in IE

Joshua Davis (JIRA) jira-events at lists.jboss.org
Thu May 14 11:11:47 EDT 2009


     [ https://jira.jboss.org/jira/browse/JBSEAM-3225?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joshua Davis updated JBSEAM-3225:
---------------------------------

    Description: 
Issuing many Seam Remoting calls can cause IE6 to fail with an 'out of memory' error.   The problem seems to be related to the fact that the AJAX request object is a COM object in IE, so it doesn't get garbage collected in the same way.  On a P3 machine with 512M of RAM, IE6 can handle about 30k calls before failing.

Here is one way to fix it using Prototype:

Seam.Remoting.sendAjaxRequest = function(envelope, path, callback, silent)
{
    Seam.Remoting.log("Request packet:\n" + envelope);

    if (!silent)
        Seam.Remoting.displayLoadingMessage();

    if (Seam.Remoting.encodedSessionId)
    {
        path += ';jsessionid=' + Seam.Remoting.encodedSessionId;
    }
    var req = new Ajax.Request(
            Seam.Remoting.resourcePath + path,
    {
        method: 'post',
        postBody: envelope,
        contentType: 'text/xml',
        evalJS: false,
        evalJSON: false,
        onSuccess: function(transport)
        {
            Seam.Remoting.requestCallback(transport,callback);
        },
        onFailure: function(transport)
        {

        }
    });
};

Seam.Remoting.requestCallback = function(req,callback)
{
    if (callback)
    {
        // The following code deals with a Firefox security issue.  It reparses the XML
        // response if accessing the documentElement throws an exception
        try
        {
            req.responseXML.documentElement;
            callback(req.responseXML);
        }
        catch (ex)
        {
            try
            {
                // Try it the IE way first...
                var doc = new ActiveXObject("Microsoft.XMLDOM");
                doc.async = "false";
                doc.loadXML(req.responseText);
                callback(doc);
            }
            catch (e)
            {
                // If that fails, use standards
                var parser = new DOMParser();
                callback(parser.parseFromString(req.responseText, "text/xml"));
            }
        }
    }
};



  was:
Issuing many Seam Remoting calls can cause IE6 to fail with an 'out of memory' error.   The problem seems to be related to the fact that the AJAX request object is a COM object in IE, so it doesn't get garbage collected in the same way.  On a P3 machine with 512M of RAM, IE6 can handle about 30k calls before failing.

Here is one way to fix it using Prototype:

{code}

Seam.Remoting.sendAjaxRequest = function(envelope, path, callback, silent)
{
    Seam.Remoting.log("Request packet:\n" + envelope);

    if (!silent)
        Seam.Remoting.displayLoadingMessage();

    if (Seam.Remoting.encodedSessionId)
    {
        path += ';jsessionid=' + Seam.Remoting.encodedSessionId;
    }
    var req = new Ajax.Request(
            Seam.Remoting.resourcePath + path,
    {
        method: 'post',
        postBody: envelope,
        contentType: 'text/xml',
        evalJS: false,
        evalJSON: false,
        onSuccess: function(transport)
        {
            Seam.Remoting.requestCallback(transport,callback);
        },
        onFailure: function(transport)
        {

        }
    });
};

Seam.Remoting.requestCallback = function(req,callback)
{
    if (callback)
    {
        // The following code deals with a Firefox security issue.  It reparses the XML
        // response if accessing the documentElement throws an exception
        try
        {
            req.responseXML.documentElement;
            callback(req.responseXML);
        }
        catch (ex)
        {
            try
            {
                // Try it the IE way first...
                var doc = new ActiveXObject("Microsoft.XMLDOM");
                doc.async = "false";
                doc.loadXML(req.responseText);
                callback(doc);
            }
            catch (e)
            {
                // If that fails, use standards
                var parser = new DOMParser();
                callback(parser.parseFromString(req.responseText, "text/xml"));
            }
        }
    }
};
{code}




> Seam Remoting JS memory leak in IE
> ----------------------------------
>
>                 Key: JBSEAM-3225
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3225
>             Project: Seam
>          Issue Type: Bug
>          Components: Remoting
>    Affects Versions: 2.0.1.GA, 2.0.2.GA, 2.1.0.SP1, 2.1.1.GA
>         Environment: IE 6
>            Reporter: Joshua Davis
>            Assignee: Shane Bryzak
>         Attachments: fix_IE_memory_leak.patch, ie6leak-example.zip, JBSEAM-3225_fix_IE6_memory_leak.patch
>
>
> Issuing many Seam Remoting calls can cause IE6 to fail with an 'out of memory' error.   The problem seems to be related to the fact that the AJAX request object is a COM object in IE, so it doesn't get garbage collected in the same way.  On a P3 machine with 512M of RAM, IE6 can handle about 30k calls before failing.
> Here is one way to fix it using Prototype:
> Seam.Remoting.sendAjaxRequest = function(envelope, path, callback, silent)
> {
>     Seam.Remoting.log("Request packet:\n" + envelope);
>     if (!silent)
>         Seam.Remoting.displayLoadingMessage();
>     if (Seam.Remoting.encodedSessionId)
>     {
>         path += ';jsessionid=' + Seam.Remoting.encodedSessionId;
>     }
>     var req = new Ajax.Request(
>             Seam.Remoting.resourcePath + path,
>     {
>         method: 'post',
>         postBody: envelope,
>         contentType: 'text/xml',
>         evalJS: false,
>         evalJSON: false,
>         onSuccess: function(transport)
>         {
>             Seam.Remoting.requestCallback(transport,callback);
>         },
>         onFailure: function(transport)
>         {
>         }
>     });
> };
> Seam.Remoting.requestCallback = function(req,callback)
> {
>     if (callback)
>     {
>         // The following code deals with a Firefox security issue.  It reparses the XML
>         // response if accessing the documentElement throws an exception
>         try
>         {
>             req.responseXML.documentElement;
>             callback(req.responseXML);
>         }
>         catch (ex)
>         {
>             try
>             {
>                 // Try it the IE way first...
>                 var doc = new ActiveXObject("Microsoft.XMLDOM");
>                 doc.async = "false";
>                 doc.loadXML(req.responseText);
>                 callback(doc);
>             }
>             catch (e)
>             {
>                 // If that fails, use standards
>                 var parser = new DOMParser();
>                 callback(parser.parseFromString(req.responseText, "text/xml"));
>             }
>         }
>     }
> };

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list