aapoalas / aapoalas/denonomicon
Expand examples to show FinalizationRegistry usage for binding GC and deallocation
- Langage dominant
- TypeScript
- Étoiles
- 33
- Forks
- 0
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Domaine
- documentation
- Type d'issue
- Documentation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 40/100