mbebenita / LLJS

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

Support for memory allocator with GC #35

Open akrymski opened 10 years ago

akrymski commented 10 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 10 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 10 years ago

How about something like Automatic Reference Counting instead?