Hi,
I’am trying to make a NIF resource and put it in the ETS, but the resource is destroyed just immediate after I have put it in ETS. Maybe someone knows what’s the matter?
For example:
iex(43)> :ets.insert :test, {5, TupleNif.tuple_to_binary({1, 2, 3})}
Destructing array: 0x14042ed0
TupleNif.tuple_to_binary({1, 2, 3} - create NIF resource.
I am added the debug output in the resource destroying NIF function, so as we can see the debug output “Destructing array: 0x14042ed0” indicates that the resource is destroyed.
iex(44)> [{k, v}] = :ets.lookup :test, 5
[{5, #Reference<0.2003688078.3595960321.242503>}]
iex(45)> TupleNif.binary_to_tuple v
Bug Bug ..!!** (ArgumentError) argument error
In the TupleNif.binary_to_tuple NIF function the ArgumentError returned if we can’t get resource from the input parameter.
OTP21