Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory usage with lots of large images

72 views
Skip to first unread message

ch...@slidestorm.net

unread,
Jul 19, 2012, 8:38:53 PM7/19/12
to
I've been working on a site that has the potential to use lots of large images. During testing I found the memory usage in Firefox to get rather large. For about 150 1680x1050 images, about:memory reports 1GB for images. Our site only shows one or two of these images at a time, but its important that they be preloaded. I'm concerned about some of our users having performance issues stemming from excessive memory usage, especially since 150 images is a bit arbitrary. I understand that Firefox holds images in memory in an uncompressed format, but is there a way to reduce memory usage? Will a future version of Firefox handle non-visible images in a more efficient way?

Boris Zbarsky

unread,
Jul 19, 2012, 11:51:35 PM7/19/12
to
On 7/19/12 8:38 PM, ch...@slidestorm.net wrote:
> I've been working on a site that has the potential to use lots of large images. During testing I found the memory usage in Firefox to get rather large.. For about 150 1680x1050 images, about:memory reports 1GB for images.

Makes sense. 150 * 1680 * 1050 * 4 == 1.05 * 10^9 or so.

> Our site only shows one or two of these images at a time, but its important that they be preloaded.

So you want them preloaded (as in, cached) but not predecoded?

Can you preload them but then not hold on to all those <img> elements?

> but is there a way to reduce memory usage?

Apart from the suggestion above, not right now.

> Will a future version of Firefox handle non-visible images in a more efficient way?

Yes, though the definition of "non-visible" is not clear yet. Your best
bet is making sure the relevant <img> elements are not in the DOM; I
believe that the plan is to not eagerly decode those.

-Boris

ch...@slidestorm.net

unread,
Jul 20, 2012, 12:27:54 PM7/20/12
to
Thanks for the reply.

> So you want them preloaded (as in, cached) but not predecoded?

Yes this would be nice.

> Can you preload them but then not hold on to all those &lt;img&gt; elements?

Even if you preload the images with an Image object the memory is still used. I even tried an experiment writing the images out to canvases, which I thought reduced the memory, but it looked like it started using video memory instead of system memory.

> Yes, though the definition of &quot;non-visible&quot; is not clear yet. Your best
> bet is making sure the relevant &lt;img&gt; elements are not in the DOM; I
> believe that the plan is to not eagerly decode those.
>
> -Boris

By non-visible I meant preloaded with javascript or images that are not rendered (display:none). Thanks for the reply.

Boris Zbarsky

unread,
Jul 20, 2012, 12:56:07 PM7/20/12
to
On 7/20/12 12:27 PM, ch...@slidestorm.net wrote:
>> Can you preload them but then not hold on to all those&lt;img&gt; elements?
>
> Even if you preload the images with an Image object the memory is still used.

My point was that if you don't actually hold on to the <img> elements
once the load is done it's possible they'll get garbage-collected and
hence reduce the memory usage by dropping the decoded data.

> By non-visible I meant preloaded with javascript or images that are not rendered (display:none).

Yeah, I think we're going to move to not decoding those eagerly at some
point. There's some work to be done there.

-Boris
0 new messages