The process which created a table is the tables's owner. If the owner terminates the table is deleted and all its resources are deleted too. You can change owner by calling ets:give_away/3
. Also you can delete tables explicitly with ets:delete/1
.
How to cleanup an ETS table after use?
Pergunta
I am creating an ETS table with an unique atom name within a process. The process executes and terminates. Will the process termination clear the ETS consumed resources (memory) ?
Is it necessary to cleanup/delete an ETS table after using ?
This is what I am doing:
parentProcess() ->
UniqueAtomTerm = 'myAtomIdentifier',
ets:new( UniqueAtomTerm, [] ),
myProc (UniqueAtomTerm).
.
myProc( UniqueAtomTerm ) ->
.... do some inserts, etc
ets:delete_all_objects( UniqueAtomTerm ).
It appears that if I try to create another ETS table with the same atom identifier, it will error, therfore the above does not appear to work. Per the above, I cannot make the ETS table options as private as I need to insert from a different process (just in case private would clear the ETS resources ).
So the bottom line question: How to remove all resources from a specific ETS table ?
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow