Question

I was playing with the process dictionary inside a gen_server module, i called get() function and i get something like this.

{'$ancestors',[main_server,<0.30.0>]},
{'$initial_call',{child_server,init,1}}]

what happen if i erased the process dictionary, what would go wrong ?
i erased it and every thing worked fine, even calling a function that generates an exception in the child_server the main_server still can get the exit signal.

Was it helpful?

Solution

$ancestors is used only in the initialization stage, to get the parent's PID, which is used to catch the EXIT message coming from the parent, so that the terminate stuff can get executed. Erasing this key when the server is up and running makes no difference.

$initial_call, on the other hand, is used in the crash report by proc_lib to dump the MFA info.

A quick grep in the OTP source tree can certainly help.

OTHER TIPS

I think some debug functions may use process dictionary, for example erlang:process_info/2

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top