Experimenting with memory allocation prior to the memory pool, I came to know that assigning 60M float to 32 arrays sometimes sometimes crashes on the browser tab (tried in Chrome)
: stirring [i] = monastery.rendum ()}
for bigArray = new Float32Array (60000000) (var i = 0; i & lt; bigArray.length; i + = 1) / code>I am allocating a total of 240 MB (i.e. Float32ARAA.BVTES_PER_ELEMENT * large array lamps) on an 8 GB machine . This tab crashes 20% of the time, and 100% if I try to inspect large amounts (e.g., big arrows in the console. Try to get the lamp, log in or, instead of viewing its contents Turn it over).
Is there no way in modern browsers (mainly Firefox and Chrome) to calculate the allocation limit (non-standard, would be complex on wish)? I want to apply a pool near the border and I would like to use that pool for all the later float array - I do not have to strictly allocate the 60M float 32 array, I would like to explore which I can try to allocate without beating my tab
Filling a big buffer like this takes some time, and possibly blocks the browser until Chrome Not enough
You need to break it into blocks, so that the browser can breathe once in a while. This will require an asynchronous approach.
In addition: Even if the browser has an arbitrary memory limit, even if it takes less time to fill it, then this tab should not crash if the memory is implemented by the run-out paging system Here also should not be a problem (slow, but available). If it still crashes under the solution, I would say that it will be a bug (see it again for reporting in Kribb.com).
Here is a way to fill a large buffer with asynchronous:
function getFilledFloat32 (size, callback) {try {var bigArray = new Float32Array (size) // Allocated buffer block size = 2 * 1024 * 1024, // 2MB block block block = block, current = 0; // init block brakes and positions (fill the function () (while the current & lt; size & amp; block & amp; block); [current ++] = monastery. Randem (); // till buffer up to the ball or block If (current and lieutenant; size) {// blocked block = block size; // reset block-size document. Explorer selector ('span'). InnerHTML + = "."! //! Bus demo set timeout (fill, 7 ); // Wait for 7ms, release} and callback // we have started, callback start}} ();} hold (error) { Evening ("Error:" + err.message);}} // --- Exam Code ---------------------------- var IsBusy = false; function filled () {If (IBB) is return; IsBusy = true; var mb = + document.getElementById ("rngMem") value; Document.query selector ('span'). InnerHTML = "fill" GetFilledFloat32 (mb * 1024 * 1024, function (buffer) {warning ("full! First two indexed: \ n" + buffer [0] + ", \ n" + buffer [1]); isBusy = false;}) ;}
label = "mem" & gt; MB in size: & lt; / Label & gt; & Lt; Input id = "rngMem" onchange = "document.query selector ('output'). Value = this.value" type = "range" min = 10 max = 500 value = 60> & Lt; Production & gt; 60 & lt; / Product & gt; & Lt; Button onclick = "fill ()" & gt; Fill & lt; / Button & gt;
No comments:
Post a Comment