Skip to content

Commit b078fec

Browse files
committed
update README.md
1 parent b1562ff commit b078fec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ obj1.setProperty("getUrl", (JSCallFunction) args -> {
149149
return "https://github.com/HarlonWang/quickjs-wrapper";
150150
});
151151
globalObj.setProperty("repository", repository);
152+
repository.release();
152153
```
153154

154155
JavaScript
@@ -183,19 +184,25 @@ repository.getString("name"); // QuickJS Wrapper
183184
repository.getInteger("created"); // 2022
184185
repository.getDouble("version"); // 1.1
185186
repository.getBoolean("signing_enabled"); // true
186-
repository.getJSFunction("getUrl").call(); // https://github.com/HarlonWang/quickjs-wrapper
187+
JSFunction fn = repository.getJSFunction("getUrl");
188+
String url = fn.call(); // https://github.com/HarlonWang/quickjs-wrapper
189+
fn.release();
190+
repository.release();
187191
```
188192

189193
### Create JSObject in Java
190194
```Java
191195
QuickJSContext context = QuickJSContext.create();
192196
JSObject obj = context.createNewJSObject();
197+
// Need to release, otherwise it will cause a memory leak.
198+
obj.release();
193199
```
194200

195201
### Create JSArray in Java
196202
```Java
197203
QuickJSContext context = QuickJSContext.create();
198204
JSArray array = context.createNewJSArray();
205+
array.release();
199206
```
200207

201208
### How to return Function to JavaScript in Java

0 commit comments

Comments
 (0)