Javascript new Image() memory management
Example code:
var image1 = new Image();
var image2 = new Image();
image1.src = "some_image.png";
image2.src = "s开发者_JAVA百科ome_image.png";
Is some_image.png loaded in memory twice, or just once?
The simplest way to test it, without any precise memory profiling tools and ignoring the fact it is actually depends on implementation, is following - try to create million of such images.
Аfter each, say, 10 thousands produce following steps (may be it is even better if one will write his observations in a notebook):
- move the mouse
- try to scroll any window opened with lengthy content
- minimize and maximize some windows
If those actions take longer and longer time after each iteration, than yes, it's look like implementor for some very unintuitive reasons treats each binary equivalent image like a separate chunk of data )
精彩评论