Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  105] [ 5]  / answers: 1 / hits: 6580  / 10 Years ago, sat, september 6, 2014, 12:00:00

I'm trying to display images with URL.createObjectURL. However, it takes so much memory, about 10 times of image size.
Here is my code:



var image = new Image();
image.src = URL.createObjectURL(blob);
image.className = 'images';
image.onload = function(){
URL.revokeObjectURL(this.src);
};
$('.images').appendTo('body');


Is this a browser bug? Or something's wrong with my code?


More From » javascript

 Answers
3

Actually you call URL.revokeObjectURL() when you release an existing object URL which was previously created by calling window.URL.createObjectURL() for optimal performance and memory usage, if there are safe times when you can explicitly unload them.



But you can't save memory through creating object, read this answer, and this helper link.


[#42675] Thursday, September 4, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tayaw

Total Points: 749
Total Questions: 88
Total Answers: 86

Location: Djibouti
Member since Sun, Feb 27, 2022
2 Years ago
tayaw questions
;