You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spannerlib/wrappers/spannerlib-node/README.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,5 +44,9 @@ async function run() {
44
44
45
45
The wrapper consists of:
46
46
1.**`src/cpp/addon.cc`**: C++ Node-API bridge that handles thread boundaries and type conversions between V8 and C.
47
-
2.**`src/ffi/utils.js`**: Helper functions to invoke native methods asynchronously using Promises.
47
+
2.**`src/ffi/utils.ts`**: Helper functions to invoke native methods asynchronously using Promises.
48
48
3.**`src/lib/`**: JavaScript classes (`Pool`, `Connection`, `Rows`) that provide a clean object-oriented interface.
49
+
50
+
### Component Interaction & Memory Management
51
+
52
+
When a JavaScript object (like a `Pool` or `Connection`) is created, it holds an ID referencing a pinned Go object in memory. The `spannerLib` singleton maintains a **`FinalizationRegistry`**. This registry allows Node.js to listen for when the JavaScript object is garbage collected. When GC occurs, the registry automatically triggers a cleanup call to the native layer to release the corresponding Go object, preventing native memory leaks even if the developer forgets to call `.close()` explicitly.
0 commit comments