On Thu, Dec 18, 2014 at 2:00 AM, Warren Seine <[email protected]> wrote:
>
> Hi guys,
>
> I'm trying to investigate a leak in our engine and was wondering why the
> memory limit would behave differently on mobile and desktop browsers. All
> mobile browsers crash with a TOTAL_MEMORY exception while desktop browsers
> don't. I'm especially trying to fix this on iPad, but that's also the case
> on Android.
>
> I thought I understood asm.js and made the following assumptions:
>
> 1. Before starting the program, Emscripten with asm.js will allocate a
> big array to simulate the RAM.
> 2. The size of the memory array depends on TOTAL_MEMORY.
> 3. Besides browser-specific optimizations, the allocated / used memory
> by a program is deterministic.
> 4. If TOTAL_MEMORY is too big for the actual device, the browser will
> immediately crash.
>
> It should throw, but perhaps some browsers don't, and return null or
something? Might add an assert right after "new ArrayBuffer" in
src/preamble.js (2 places), to see if that catches anything (but it
shouldn't).
> What I'm experiencing clearly shows that I'm wrong about assumptions #3
> and #4, so here's a few questions:
>
> - Do browsers perform some "virtual memory" allocation of the asm.js
> array? Some trick that would make a 256 MB array not crash in Safari Mobile
> until being actually filled with data.
>
>
They might, sure, just like any allocation. I know that on linux malloc
will eagerly return success, and when pages are actually used, problems
might happen.
I would guess mobile browsers would be careful about this, but that's just
a guess. Can file a bug to ask them.
>
> - What would be a safe TOTAL_MEMORY value for mobile browsers?
>
>
Depends on the device. However, you should probably just use a very small
TOTAL_MEMORY, and enable heap growth. That slows you down a little, but is
more memory efficient. We are also making memory growth faster.
>
> - What's the best technique for memory profiling in JavaScript when
> using asm.js? Can --profiling help profiling memory if the memory
> array is preallocated?
>
>
juj has a memory profiling tool, I don't remember where it is though.
>
> - What's the role of the memory initialization file? What does it
> contain on startup?
>
>
>
It contains what memory is initialized with. So static global variables,
etc. If you have printf("hello world"); then that string will be in there
somewhere, for example.
- Alon
> Thanks a lot,
> Warren.
>
> --
> 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.
>
--
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.