[whatwg] Proposal for separating script downloads and execution

Boris Zbarsky bzbarsky at MIT.EDU
Thu Feb 17 09:05:56 PST 2011


On 2/17/11 11:39 AM, Kyle Simpson wrote:

> Memory leak in the sense that the page is holding onto more memory than
> it *potentially* needs to. But not memory leak in the sense that this
> memory stays around after the page unloads/reloads, right?

Right.

> I dunno if
> I'd call that a "memory leak" as much as I'd call it a "higher memory
> utilization", or maybe "potential memory waste".

Most users will call continuously increasing memory (which is what you'd 
get if a page creates script elements, sets src, and then doesn't insert 
them, perhaps by accident) a memory leak.

> How much memory does a 25k JavaScript file take up while sitting in this
> queue? Is it roughly 25k

It depends.  In Gecko right now it's probably about 25k, but it might be 
50k if conversion to UTF16 happens earlier, and so forth.

> or is it a lot more? Compared to the 100-300
> MB of memory that a Firefox instance takes up on my computer, what
> percentage of that would be (or would be increased) if Firefox were also
> holding onto even a large amount (~200k) of not-yet-used JavaScript code
> in memory?

My worries are cases where a page inadvertently makes you hold on to 
tens or hundreds of megabytes of js, not about the 200k case.

> Also, we have to consider whether the intended usage of this feature, by
> developers, is to unnecessarily waste bandwidth and memory and never use
> the scripts, or if it's in good-faith to eventually use them. Does that
> mean there will never be any memory waste? No. But I don't think it'll
> be the norm, at least based on the interested parties in this discussion.

I think you understimate how often scripts just have bugs in them.  I'm 
not saying someone would create a few million nodes and then not insert 
them in the DOM because they're _trying_ to do something dumb.  But that 
sort of thing scripts do all the time.

> I'd venture to guess that right now, there's a pretty small amount of
> code out there which is creating script elements en masse but not
> appending them to the DOM. Can't imagine really what that use-case would
> be

You're assuming scripts mean to do everything they do.  That's not a 
good assumption, unfortunately.

-Boris


More information about the whatwg mailing list