aapoalas / aapoalas/denonomicon

Expand examples to show FinalizationRegistry usage for binding GC and deallocation

未关闭
#12 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
33
派生
0
PR 合并指标
30 天内没有已合并 PR

描述

I am trying to port a c++ library to deno and I am not clear on how gc with ffi buffers works.

This is a great explanation of how ffi works, but I cannot understand the connection with gc.

I saw this example

https://github.com/aapoalas/denonomicon/blob/5da9957a350e146aec203b93bb8621805569f8c0/examples/cpp/inheritedClass.ts#L225C7-L225C26

but I do not understand how the gc is informed that it needs to call a destructor when the buffer/pointer goes out of scope in deno.

I have done the same in node and a function like this

https://nodejs.org/api/n-api.html#napi_create_external

makes it super easy.

I could not understand what is the equivalent in deno.

贡献指南

这个仓库没有索引到贡献指南

调研方向

Look at the existing examples in the repository, especially the inheritedClass.ts file linked in the issue. Understand how FinalizationRegistry is used in Deno FFI to manage garbage collection of external buffers. The goal is to add a clear example showing the equivalent of Node.js's napi_create_external for Deno, explaining how to set up a destructor callback when a pointer goes out of scope.

由索引模型根据 Issue 内容生成。

评估

领域
documentation
Issue 类型
文档
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
40/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。