javascript - Large strings with Papa parse cause Chrome and Opera to crash -


papa parse appears causing chrome , opera crash (windows 7) if attempt parse "large" csv strings of 1 million rows 20 columns. same page loads in firefox. chrome , opera crash before calling parse if have large csv string defined , include <script> tag papaparse.js library. if don't include <script> tag papaparse.js there no problems creating large csv strings can't parse them. in actual use case, not generating large csv strings in javascript rather pulling them out of zip archive. doesn't appear make difference if use step or chunk functions. can run test case here; test case problem code;

<!doctype html> <html>  <script src="http://papaparse.com/resources/js/papaparse.js"></script>  <body>  <script>   function my_createmockcsv(rows) {   var my_csv="a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v\r\n";   (var i=1; i<rows; i++) {    my_csv+= i+","+ i+","+ i+","+ i+","+ i+","+ i+","+ i+","+ i+","+             i+","+ i+","+ i+","+ i+","+ i+","+ i+","+ i+","+ i+","+             i+","+ i+","+ i+","+ i+","+ i+","+ i+","+"\r\n";    }  return my_csv;  }   function parsecsv(csv) {   var rowcount=0;   papa.parse(csv,                 {                delimiter: ',',                 worker: false,                encoding: 'default',                header: true,                chunk: function(results) {                  rowcount+= results.data.length;                 console.log("parsed rows: "+rowcount);                },              complete: function (results) {                   console.log("complete - parsed: "+rowcount+" rows");                }             });   }  function run_testcase() {  rows=document.getelementbyid("rows").value;  //parsecsv(my_createmockcsv(rows));    console.log("begin generating csv ...");  alert("about generate mock csv");  var my_csv=my_createmockcsv(rows);  console.log("end generating csv ...");  alert("about parse mock csv");  parsecsv(my_csv); }  </script>  papaparse test case script: crash chrome, opera<br/>  rows: <input id="rows" type="number" value="1000000"> (try around 1mil rows) <button onclick="run_testcase();">run</button>  </body> </html> 

papa parse isn't causing browser crash.

chrome , opera not efficient strings firefox is. cannot create string million rows , 20 columns in memory you're doing , expect browser tab remain stable.

comment out call papa.parse() , you'll see mean: browser still crashes.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -