Open berendsliedrecht opened 1 year ago
Wouldn't you have the same issue passing in a string, in that the buffer needs to be freed afterward?
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.
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