On Sat, Mar 12, 2016 at 6:27 AM, Brian Barnes <[email protected]> wrote:
> Request 1: Add a System module, and one call I need System.gc();

I do not think this is wise to make such calls, at least not the same
way they are implemented in the shell.

Currently the shells have a global gc function, which is blocking the
execution.  Blocking the execution means that your JavaScript might
prevent the browser from rendering the next frame.
So if such global function is added, this would at least be asynchronous.

As you mention, this can be mis-used, a simple example would be:

  for (var x of array)
    System.gc();

>From what I think such function would be better as an hint for triggering GCs.

I want to note that currently, GCs are triggered based on the
allocations, this gc() function highlight one kind of information
which is usually available in static languages.  In static languages,
we have a "new" and a "delete" function, maybe it would make sense to
sense to have a similar function as an hint for potentially unused
memory.

  System.unused(obj); obj = null;

In which case, this would be a good hint, as the engine would now have
the potential for making estimates on the amount of memory which can
be reclaimed.  Thus deciding or not to compact the heap.

I also think that this could be used as an assertion for developers,
in which case the engine can later warn the developer that objects
which were supposed to be unused are still alive when the GC is
executed.

-- 
Nicolas B. Pierron
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to