Skip to content

Commit e05f4b9

Browse files
committed
Update README.md to include information about how node-java handles memory.
1 parent 5ea9f9b commit e05f4b9

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,10 @@ ShutdownHookHelper.setShutdownHookSync(java.newProxy('java.lang.Runnable', {
478478
}));
479479
```
480480
481+
# Object lifetime
482+
483+
When you call a Java method through node-java, any arguments (V8/JavaScript objects) will be converted to Java objects on the v8 main thread via a call to v8ToJava (found in utils.cpp). The JavaScript object is not held on to and can be garbage collected by v8. If this is an async call, the reference count on the Java objects will be incremented. The Java method will be invoked in a node.js async thread (see uv_queue_work). When the method returns, the resulting object will be returned to the main v8 thread and converted to JavaScript objects via a call to javaToV8 and the Java object's reference count will then be decremented to allow for garbage collection. The resulting v8 object will then be returned to the callers callback function.
484+
481485
## License
482486
483487
(The MIT License)

0 commit comments

Comments
 (0)