mbebenita / LLJS

LLJS: Low-Level JavaScript
http://lljs.org
Other
1.18k stars 89 forks source link

Support for memory allocator with GC #35

Open akrymski opened 11 years ago

akrymski commented 11 years ago

The LLJS memory allocator does not support automatic garbage collection currently. Would be nice to be able to switch GC on/off when compiling. If the GC is turned on, the memory allocator would fall back to not using an ArrayBuffer at all - thus running like regular js. Alternatively could even try adding a Boehm GC to LLJS :)

mbebenita commented 11 years ago

Part of the reason to use something like LLJS is to avoid automatic memory management, but someone could certainly implement a Boehm GC however it can get quite complicated since pointers can leak into plain JS objects. The other researchy problem is what to do with dead JS objects that hang on to malloc allocated things. In JS, there is no way to get notified of or detect that an object is about to be garbage collected, so there is no opportunity to free the malloc'ed memory.

akrymski commented 11 years ago

How about something like Automatic Reference Counting instead?