beamjs/erlv8 — pull request #68 by Licenser (2012-02-21 13:45:59+00:00)
Title: Lots of updates, concurrency and memory management

I implemented isolates as encapsulation for all VM processes, this way they don't get into eachothers contexts. Some restructuring was needed and my first fear was that I'd break the memory management, but actually isolates improved the situation.

new features are:
* Isolation of each erlv8_vm:start() vm into an own isolate.
* erlv8_vm:kill(VM) - kills the running script.
* fix of an memory leak when creating and discarding VM's (at least mostly)

All but one test are running (no degradation detected).

For the memory issue I rant he following test:

```erlang
application:start(erlv8).
S = lists:seq(0, 10000, 1).
lists:map(fun(I) -> {ok, VM} = erlv8_vm:start(), erlv8_vm:stop(VM) end,S).
```

The code creates and discards 10k VM's here are my results (taken from top not 100% accurate but it shows the tendency good enough)

current HEAD version:
```
31023 beam.smp 99.8 02:53.14 16/1 0 8390 20348 1119M 216K 1108M 1258M 4179M 31023 481 running 501 331422 202 52435 26214 883498+ 13457640 413992+ 563 39M 7770K licenser
# Fatal error in CALL_AND_RETRY_2
# Allocation failed - process out of memory
#

Abort trap: 6
```

New Isolate Version:
```
31038 beam.smp 0.0 04:30.86 16 0 10054 10171 131M 216K 136M 230M 3183M 31038 481 sleeping 501 3414413 202 200297 100147 1426957+ 15429276 736603+ 0 43M 5994K licenser

[ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,
ok,ok,ok,ok,ok,ok,ok,ok,ok,ok|...]
```