Bug 39825 - Memory retention using timers (when viewing inspector timeline)
Summary: Memory retention using timers (when viewing inspector timeline)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.6
: P2 Major
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-27 03:48 PDT by Christopher Hunt
Modified: 2014-12-04 16:03 PST (History)
6 users (show)

See Also:


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

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Hunt 2010-05-27 03:48:44 PDT
Created attachment 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 Simon Fraser (smfr) 2010-05-27 18:26:13 PDT
I hope the timeline profiler excludes memory use by the inspector itself.
Comment 2 Geoffrey Garen 2010-05-27 23:46:07 PDT
(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 Christopher Hunt 2010-05-28 01:03:18 PDT
Hi Geoff. Do you have a feel for whether this issue is easily resolved?
Comment 4 Geoffrey Garen 2010-05-28 10:07:41 PDT
(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 Christopher Hunt 2010-06-01 19:50:41 PDT
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 Simon Fraser (smfr) 2010-06-01 20:33:43 PDT
> 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 Christopher Hunt 2010-06-01 20:40:35 PDT
(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 Christopher Hunt 2010-06-01 21:34:58 PDT
(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 Christopher Hunt 2010-06-01 21:36:04 PDT
Created attachment 57619 [details]
Screen shot of memory profile using Instruments
Comment 10 Christopher Hunt 2010-06-08 04:56:37 PDT
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 Christopher Hunt 2010-07-24 15:41:34 PDT
Created attachment 62510 [details]
Sample HTML file to reproduce the issue

Attached an HTML/JS file that easily illustrates the problem.
Comment 12 Christopher Hunt 2012-07-08 00:33:45 PDT
Still a problem with Lion, and also occurs with the Canary build of Chrome. Any interest at all out there?
Comment 13 Brian Burg 2014-12-04 16:03:42 PST
This should be resolved now that Inspector runs in its own process. Please re-open or file new bug if you feel that's not the case.