Bug 39825 - Memory retention using timers (when viewing inspector timeline)
: Memory retention using timers (when viewing inspector timeline)
Status: UNCONFIRMED
: WebKit
Web Inspector (Deprecated)
: 528+ (Nightly build)
: Macintosh Intel Mac OS X 10.6
: P2 Major
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2010-05-27 03:48 PST by
Modified: 2012-07-12 16:21 PST (History)


Attachments
Screen shot of memory consumption (150.16 KB, image/png)
2010-05-27 03:48 PST, Christopher Hunt
no flags Details
Screen shot of memory profile using Instruments (137.24 KB, image/png)
2010-06-01 21:36 PST, Christopher Hunt
no flags Details
Sample HTML file to reproduce the issue (370 bytes, text/html)
2010-07-24 15:41 PST, Christopher Hunt
no flags Details


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2010-05-27 03:48:44 PST
Created an attachment (id=57216) [details]
Screen shot of memory consumption

I'm wondering if there's a memory retention issue given the use of timers. Here's some html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html>
    <head>
        <title>Timer Memory Retention</title>
    </head>
    <body>
        <p>Please observe memory usage with the timeline profiler.</p>
        <script type="text/javascript">
            setInterval(null, 100);
        </script>
    </body>
</html>

What we have is a script that simply sets up a timer to execute every 100ms. It makes no difference to the test whether a function is called on the timer firing.

If you load this and then use the timeline profile then you should observe memory continue to be consumed. Within a couple of minutes memory usage doubles. I have had this running for several minutes with no apparent reduction in the rate of memory consumed.

I have attached a screenshot of the memory consumption timeline.
------- Comment #1 From 2010-05-27 18:26:13 PST -------
I hope the timeline profiler excludes memory use by the inspector itself.
------- Comment #2 From 2010-05-27 23:46:07 PST -------
(In reply to comment #1)
> I hope the timeline profiler excludes memory use by the inspector itself.

It doesn't. That could be the issue.
------- Comment #3 From 2010-05-28 01:03:18 PST -------
Hi Geoff. Do you have a feel for whether this issue is easily resolved?
------- Comment #4 From 2010-05-28 10:07:41 PST -------
(In reply to comment #3)
> Hi Geoff. Do you have a feel for whether this issue is easily resolved?

If the Web Inspector guess is true, it's not easily resolved. We would need to move the Web Inspector to use a separate heap/JSGlobalData. Doable, but nontrivial.
------- Comment #5 From 2010-06-01 19:50:41 PST -------
I've now downloaded WebKit and built it. I'd be happy to have a go at fixing this issue if someone can point me in the right direction. I have a memory retention issue in my application in production and I simply must nail down what is causing it so I'm keen to help!
------- Comment #6 From 2010-06-01 20:33:43 PST -------
> I have a memory retention issue in my application in production
Is this on Mac OS X? Have you tried the simple stuff, like running 'leaks'?
------- Comment #7 From 2010-06-01 20:40:35 PST -------
(In reply to comment #6)
> Is this on Mac OS X? Have you tried the simple stuff, like running 'leaks'?

I confess to not having tried leaks - I've not been regarding the problem as a memory leak; more of a retention issue within Javascript. I shall of course try this, though I'd still like to help with this particular issue. It seems to me that the memory profiler being introduced is de-valued if there is a fundamental issue in its consideration of gathering metrics.
------- Comment #8 From 2010-06-01 21:34:58 PST -------
(In reply to comment #7)

I just profiled the app using leaks as part of Instruments under OS X. What I found was that WebKit/Safari does *not* appear to be leaking memory adding strength to the view that the memory profiler of WebKit is not considering its own object allocations in its output. I attach the Instruments view over several minutes of running WebKit/Safari (debug build).

Any ideas then on where I should start looking in the WebKit code with a view to helping fix the memory profiler part of the Web Inspector?
------- Comment #9 From 2010-06-01 21:36:04 PST -------
Created an attachment (id=57619) [details]
Screen shot of memory profile using Instruments
------- Comment #10 From 2010-06-08 04:56:37 PST -------
Anyone out there care to point me toward some doco that gives an introduction to the Web Inspector architecture, or better still a hint on where to start looking? I would have thought they'd be some interest in getting this problem resolved...
------- Comment #11 From 2010-07-24 15:41:34 PST -------
Created an attachment (id=62510) [details]
Sample HTML file to reproduce the issue

Attached an HTML/JS file that easily illustrates the problem.
------- Comment #12 From 2012-07-08 00:33:45 PST -------
Still a problem with Lion, and also occurs with the Canary build of Chrome. Any interest at all out there?