javascript - window.URL.revokeObjectURL() doesn't release memory immediately (or not at all)? -


i'm making html interface upload images on server drag & drop , multiple selection files. want display pictures before sending them server. first try use filereader have had problems in this post. change way , decided use blob:url ebidel recommands in post, window.url.createobjecturl() , window.url.revokeobjecturl() release memory.

but now, i've got problem, wich similar this one. want client upload 200 images @ time if wants. browser crashed , ram used high! thought maybe images displayed @ same time, , set system waiting queue of files using array, in order treat 10 files @ time. problem still occurs.

on google chrome, if check chrome://blob-internals/ files (which released window.url.revokeobjecturl()) released approximatively after 8 seconds delay. on firefox i'm not sure seems if files not released (i check on about:memory -> images that)

is code bad, or problem independent of me? there solution force navigators release immediatelly memory? if can help, part of javascripton wich problems occurs: (sorry give here link because of image spam mechanism new members) http://www26.zippyshare.com/v/14195278/file.html.

edit

this kind of own answer + answer bennlich (too long text comment)

i understood answer of user1835582 indeed remove blob/file while browser needs images keeps them somewhere in memory (which logical). it's fact display images (many & heavy) gave me crashes & slow downs, not revokeobjecturl method. moreover, each browser manages memory own way, leading different behaviors. here how came conclusion.

first, let's try revokeobjecturl works well, simple example using source code of https://developer.mozilla.org/en-us/docs/using_files_from_web_applications#example.3a_using_object_urls_to_display_images. using chrome can verify blob revoked, checking chrome://blob-internals/ or trying open displayed images new tab blank. note : release blob references, add document.getelementbyid("fileelem").value = "". when posted question years ago, 8 seconds release blob, it's immediate (probably due improvements in chrome & / or better computer)

then, time charge test. did hundred of jpg of ~2.5 mo each. after images have been displayed, scrolled page. chrome crashed , firefox slow (not tested on others browsers). however, when commented li.appendchild(img) went well, huge bunch of images. shows problems not coming revokeobjecturl method in fact works properly, displaying lot of heavy images. can test create simple html page hundreds of heavy images , scroll => same result (crash / slow down).

finally deeper images memory management, it's interesting on firefox about:memory. example saw when window active, firefox uncompresses images (images -> uncompressed-heap goes up), while raw (images -> raw) stable (relative the quantity of images loaded). there discussion memory management here : http://jeff.ecchi.ca/blog/2010/09/19/free-my-memory.

with window.url.revokeobjecturl() can [blob] or [file] object. can not force remove memory.

note. browsers not finalized , can leak these facilities. if implement animation, have understand @ own risk.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -