Page 1 of 3 123 LastLast
Results 1 to 10 of 26
  1. #1
    Power Member
    Join Date
    Nov 2012
    Posts
    182

    "Out of memory" errors in Safari

    Here is the scenario:

    I have a login screen in an application that sits waiting for the user to enter their credentials. There is also a LS listener on the page that shows the user the total number of active users there are currently logged in.

    Overnight, the LS server gets shut down for several hours for backups to take place.

    If I leave this page up in a Safari browser during this period, Safari eventually crashes. In the console, I can see "Out of memory" errors logged from line 38 in the lightstreamer.js code.

    It is difficult to see what this line of code is doing because it is minified.

    Some time ago, to prevent the lightstreamer.js code generating loads of console messages while the server is down, my own wrapper code detects a "DISCONNECTED:WILL-RETRY" status change and after a short period of time will disconnect from the server completely - so there is no websocket activity at all. It only reconnects after a keypress, mousdown or touchstart event on the page itself. In other words, everything is idle until the user comes back (usually in the morning) and starts work again. The LS connection starts again and all is well.

    I suspected that something is not working as well in Safari, and that the "out of memory" error is simply the fact that the console was full - but there is no evidence of that. I cannot see what is going on that is causing the LS code to run out of memory in Safari.

    Any ideas?

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    hello,

    a couple of question first,
    which safari version on which OS?

    did you leave safari with the console open? Have you tried without opening the console (through all the life of the page)?

  3. #3
    Power Member
    Join Date
    Nov 2012
    Posts
    182
    This is Safari 5.1.7 (7534.57.2) running under 64bit Windows 7.

    This evening I will try it with the console closed and a "beautified" version of lightstreamer.js to get a better idea of the crash line.

    With regards to console, if I shut down the LS server, I do not see the usual "errors" that you see when you have (for example) the console open in Chrome when the LS client goes into its reconnect attempt loop. You do see the "create_session.js" calls in the network tab though.

    I can confirm that my code is disconnecting the LS connection after 5 minutes of retrying, so there is nothing "happening" as far as I can tell.....no idea why it would run out of memory when nothing is happening.

    When a connection is established, I just see repeated calls to bind_session.js in the network tab.

  4. #4
    Power Member
    Join Date
    Nov 2012
    Posts
    182
    Another piece of information that may be relevant. My LS connections are shared using the PC IP address as the sharing id. I have sessions open in Opera, Chrome and IE usually (when Safari barfs). They will all have disconnected from the server after it has been offline for 5 minutes.

  5. #5
    Power Member
    Join Date
    Nov 2012
    Posts
    182
    Left it overnight without the console/developer tools active and the browser still crashed.....but without the console open I cannot post the line number that failed or anything. Interestingly, I did this on another PC at the same time and that one did not crash!.

    I will retest that to make doubly sure, and get the section of code that fails.

  6. #6
    Power Member
    Join Date
    Nov 2012
    Posts
    182
    Since applying the latest patch to the client for the small issue with chrome, it hasn't crashed again! I will monitor it.

  7. #7
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    ok, let us know.

  8. #8
    Power Member
    Join Date
    Nov 2012
    Posts
    182
    OK, so contrary to my last post, this is still happening. We left Safari alive overnight (with no developer tools active) and it crashed with an "out of memory" error on line 657. I know this will not tie up with your own line numbers as it is just my beautified version of your minified script, but here it is anyway. I hope it provides a clue:

    Line 657 says
    Code:
    for (0 >= j.length && (k = 0); 0 < n.length;) a = n.shift(), a.WY = m + a.tt, a.Bt = k++, j.push(a)
    and appears here
    Code:
    define("lsi", ["lsr", "lss", "lsc", "lsa", "lsda"], function (g, e, d, c, h) {
        function b(a, k) {
            return a.WY == k.WY ? a.Bt - k.Bt : a.WY - k.WY
        }
    
    
        function a() {
            l && clearInterval(l);
            l = setInterval(i, f);
            c.Ts() && "undefined" != typeof postMessage && d.addEvent("message", function (a) {
                if ("Lightstreamer.run" == a.data && "*" == p || a.origin == p) o = !1, i()
            }, !0)
        }
    
    
        function i() {
            if (e.jT) clearInterval(l);
            else {
                m = g.gf();
                if (0 < j.length) {
                    j.sort(b);
                    for (var a; 0 < j.length && j[0].WY <= m && !e.jT;) a = j.shift(), a.Zp && (y.af(a),
                        a.tt && n.push(a))
                }
                for (0 >= j.length && (k = 0); 0 < n.length;) a = n.shift(), a.WY = m + a.tt, a.Bt = k++, j.push(a)
            }
        }
        var f = 50,
            j = [],
            m = g.gf(),
            n = [],
            l = null,
            o = !1,
            k = 0,
            p = c.Ts() && "file:" != document.location.protocol ? document.location.protocol + "//" + document.location.hostname + (document.location.port ? ":" + document.location.port : "") : "*",
            u = h.Wi(h.EXECUTOR),
            y = {
                toString: function () {
                    return ["[|Executor", f, j.length, "]"].join("|")
                },
                hO: function () {
                    o || (o = !0, c.Ts() && "undefined" != typeof postMessage && window.postMessage("Lightstreamer.run", p))
                },
                dO: function () {
                    return j.length
                },
                aN: function (a, b, i) {
                    return {
                        Zp: a,
                        so: b || null,
                        vs: i || null,
                        Bt: k++
                    }
                },
                um: function (a, k, b) {
                    a.tt = b ? k : null;
                    a.WY = m + parseInt(k);
                    if (isNaN(a.WY)) throw "lsi error time: " + a.WY;
                    j.push(a)
                },
                pk: function (a, k, b, i) {
                    return this.vb(a, k, b, i, !0)
                },
                nO: function (a) {
                    a && (a.Zp = null, a.tt = null)
                },
                vb: function (a, k, b, i, c) {
                    a = this.aN(a, b, i);
                    this.um(a, k, c);
                    0 == k && this.hO();
                    return a
                },
                Vk: function (a, k, b) {
                    a.vs[k] = b
                },
                VB: function (a, k) {
                    a.vs = k
                },
                Rl: function (a, k) {
                    a.WY += k
                },
                af: function (a, k) {
                    try {
                        var b = k || a.vs;
                        a.so ? b ? a.Zp.apply(a.so,
                            b) : a.Zp.apply(a.so) : b ? a.Zp.apply(null, b) : a.Zp()
                    } catch (i) {
                        b = null;
                        try {
                            b = a.Zp.name || a.Zp.toString()
                        } catch (c) {}
                        u.ZV(h.Wu(283), i, b)
                    }
                }
            };
        c.bx() ? setTimeout(a, 1) : a();
        return y
    });
    Last edited by kpturner; March 6th, 2014 at 12:37 PM.

  9. #9
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    That gives me no clue actually. That's the only piece of code that runs when the client is disconnected.
    I'm going to try and reproduce the issue and I will let you know.

  10. #10
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    I had no "luck" with a disconnected client, tonight I'll try with a "will-retry" client.

    In the meanwhile, did you try to track safari with perfmon?

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 04:08 PM.