Skip to content

Improve reference behavior #60

Open
@j-f1

Description

I made a small change to report whenever an object ref is deleted:

---
 Runtime/src/index.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Runtime/src/index.ts b/Runtime/src/index.ts
index 0e641ff..ddfba4e 100644
--- a/Runtime/src/index.ts
+++ b/Runtime/src/index.ts
@@ -93,6 +93,7 @@ class SwiftRuntimeHeap {
     release(ref: ref) {
         const value = this._heapValueById.get(ref);
         const isObject = typeof value == "object"
+        console.log('dereferencing', value);
         if (isObject) {
             const entry = this._heapEntryByValue.get(value)!;
             entry.rc--;

(copy the content of the code block and run pbpaste | git apply in your terminal to make this change)

It reports many deallocations. The thing that caught my attention was the repeated deallocation of functions (like toString and hasOwnProperty). I wonder if there’s a way to recognize functions that are part of the JavaScript language and either dynamically call them when needed or mark them so they don’t get released.

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions