reference leak

This commit is contained in:
ekibun
2021-01-26 21:48:43 +08:00
parent 896d563ba8
commit 3fdeca56a2
11 changed files with 1182 additions and 1059 deletions

View File

@@ -35,11 +35,15 @@ try {
}
```
Method `close` can destroy quickjs runtime that can be recreated again if you call `evaluate`. Parameter `port` should be close to stop `dispatch` loop when you do not need it.
Method `close` can destroy quickjs runtime that can be recreated again if you call `evaluate`. Parameter `port` should be close to stop `dispatch` loop when you do not need it.
```dart
engine.port.close(); // stop dispatch loop
engine.close(); // close engine
try {
engine.port.close(); // stop dispatch loop
engine.close(); // close engine
} on JSError catch(e) {
print(e); // catch reference leak exception
}
engine = null;
```
@@ -72,6 +76,13 @@ or use `invoke` method to pass list parameters:
(func as JSInvokable).invoke([arg1, arg2], thisVal);
```
`JSInvokable` returned by evaluation may increase reference of JS object.
You should manually call `release` to release JS reference:
```dart
(func as JSInvokable).release();
```
### Use modules
ES6 module with `import` function is supported and can be managed in dart with `moduleHandler`: