File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ obj1.setProperty("getUrl", (JSCallFunction) args -> {
149149 return " https://github.com/HarlonWang/quickjs-wrapper" ;
150150});
151151globalObj. setProperty(" repository" , repository);
152+ repository. release();
152153```
153154
154155JavaScript
@@ -183,19 +184,25 @@ repository.getString("name"); // QuickJS Wrapper
183184repository. getInteger(" created" ); // 2022
184185repository. getDouble(" version" ); // 1.1
185186repository. 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
191195QuickJSContext context = QuickJSContext . create();
192196JSObject 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
197203QuickJSContext context = QuickJSContext . create();
198204JSArray array = context. createNewJSArray();
205+ array. release();
199206```
200207
201208### How to return Function to JavaScript in Java
You can’t perform that action at this time.
0 commit comments