Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFI_OBJECTS can become an issue for the JavaScript wrapper. #73

Open
berendsliedrecht opened this issue Jan 23, 2023 · 2 comments
Open

Comments

@berendsliedrecht
Copy link
Contributor

Right now, the anoncreds library has a static hash map to keep all the anoncreds objects, and their associated handle, in memory for access later on. This works fine for languages with a deconstructor, but can be very tedious in languages without a deconstructor, like JavaScript.

We (@TimoGlastra and I) were wondering if it makes sense to just pass a stringified JSON into the library which would remove this issue entirely. It does make referencing a previous anoncreds object a bit more annoying, but it would prevent any unwanted memory leaks.

Timo also mentioned that this is how the indy-sdk has done it. Was there a specific reason why anoncreds derived from that?

cc: @andrewwhitehead @TimoGlastra

@andrewwhitehead
Copy link
Member

Wouldn't you have the same issue passing in a string, in that the buffer needs to be freed afterward?

@berendsliedrecht
Copy link
Contributor Author

Wouldn't you have the same issue passing in a string, in that the buffer needs to be freed afterward?

That would be handled by the GC of the JavaScript runtime. So with the string, once it's out-of-scope (or however the GCs in V8 work) it will be freed but we cannot give a method that should be called when the anoncreds object class, which contains the handle, gets garbage collected. I believe there are some RFCs open for this issue, but it won't be added anytime soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants