We at the Harvard-Smithsonian Center for Astrophysics are developing the 
next generation of astronomical image display: JS9, a Web-based version of 
the de facto standard DS9 (desktop) program. We are using emscripten 1.29.X 
to incorporate widely-used astronomical libraries into JS9.  See 
http://js9.si.edu, which utilizes a standard world coordinate system 
library, compiled to JS, to display astronomical positions as the mouse is 
moved over the image. Emscripten is a fantastic idea that will make it 
possible for our community to transition from desktop to cloud without 
having to re-write millions of lines of debugged C code.

We currently are incorporating the de facto standard astronomical I/O 
library called cfitsio into JS9 via emscripten.  Everything works as 
expected to display astronomical images of varying sizes, with one glaring 
exception: if a data file is "too large", a request to malloc too much heap 
space hangs the browser instead of returning an error. We realize that 
there is a limit to the amount of memory that can be allocated, but it 
would be preferable to recover gracefully from such a request.

As an extreme example, the test program below will hang both FF and Chrome. 
Obviously, we see the hang with smaller requests, depending on how much 
heap space has already been allocated.

Any help would be appreciated.

Eric Mandel

#include <stdio.h>
#include <stdlib.h>

//  emcc -s TOTAL_MEMORY=67108864 -s ALLOW_MEMORY_GROWTH=1 -o test.html 
test.c
int main(){
  int bytes=2000000000;
  int i, tot=0;
  char *buf=NULL;
  printf("alloc: %d bytes of memory ... ", bytes);
  buf = malloc(bytes);
  if( buf ){
    printf("got it!\n");
    for(i=0; i<bytes; i++){buf[i] = 1;}
    for(i=0; i<bytes; i++){tot += buf[i];}
    printf("total: %d\n", tot);
  } else {
    printf("could not allocate memory\n");
  }
  return 0;
}

-- 
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