4 ms·
asm.js does not turn off garbage collection. Instead, programs written in this style do not allocate many objects, so the garbage collector does not need to run
by mccr8 13y ago
asm.js does not turn off garbage collection. Instead, programs written in this style do not allocate many objects, so the garbage collector does not need to run much. asm.js programs allocate a single giant block of memory, and then do their own psuedo-manual-memory-management within that block.
- mistercow 13y agoFrom the asmjs.org FAQ: >Q. Why not just keep optimizing JavaScript JIT compilers instead? >A. No need to stop! But JIT compilers have less predictable performance based on complicated heuristics. The asm.js model provides a model closer to C/C++ by eliminating dynamic type guards, boxed values, and garbage collection.
- Timmmmbob 13y agoHe's saying it eliminates garbage collection by emitting code that doesn't dynamically allocate any objects. The GC is still active it just never needs to do anything. If you remove the 'use asm' pragma the code will still not allocate any objects and hence the GC will still never need to do anything.
- mistercow 13y agoAh, I see what you're saying. The point being that you still have the GC for any non-asm.js code on the same page. And I suppose by the same token, you could "opt out" of GC without asm.js by using various techniques to eliminate allocations.