Thanks for pointing out #3253, where mention of an infinite loop is similar 
to the behavior we are seeing (the CPU becomes pegged at 100% during the 
hang). From the discussion, it was unclear whether the new incoming code 
added a fix for the infinite loop problem, i.e. is the "assert" you mention 
part of the new fixes? That might be what we need, in conjunction with 
malloc() returning null if it cannot allocate memory. In our case, the 
user/researcher has to decide which data set to close (at which point we 
would clean up allocation in the heap), so all we can do is alert her to 
the problem and clean up any images she chooses to close.

Regarding possible browser bugs: I made a slightly different test of direct 
typed-array memory allocation in JS (no emscripten) and this seems to work 
fine. if you allocate 200Mb at a time, FF will happily use many Gb of 
memory. Because of this, I think we should pursue the incoming emscripten 
fixes and see where that gets us.

Perhaps this discussion be merged with #3253.

Eric

[Not using jsfiddle to avoid some curious person hanging their machine!]

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      #container1 {
        background: lightblue;
        padding: 10px;
        width: 250px;
        height: 250px;
      }
    </style>
  </head>
  <body onload="init()">
    <div class="container" id="container1"></div>
    <script>
      var bytes = 200000000;
      var niter = 100;
      function init(){
        var i, id, intv, buf = [];
        var j=1, total = 0;
        id = document.getElementById("container1");
intv = window.setInterval(function(){
            id.innerHTML = "alloc: " + bytes + " bytes, niter: " + j;
            buf[j] = new Uint8Array(bytes);
            for(i=0; i<bytes; i++){ buf[j][i] = 1; }
            id.innerHTML += "<br>&nbsp;&nbsp;set ...";
            for(i=0; i<bytes; i++){ total += buf[j][i]; }
            id.innerHTML += "<br>total: " + total;
            if( j++ === niter ){ window.clearInterval(intv); }
}, 1000);
      }
    </script>
  </body>
</html>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to