1

I ask because

  1. there doesn't seem to a be a good way to represent Pids in a way that can be encoded in JSON (for trading messages with a web-based client),
  2. it would therefore be convenient to register processes that represent these messages to the client using an alternate identifier of some kind, like a serial number or timestamp, however
  3. processes are registered using atoms, and
  4. although names are "unregistered" when their processes die,
  5. atoms in the Erlang VM are not garbage collected.

So registering a large number of processes consumes memory that is never recovered, right? Or does unregistering the name also clean up the atom?

4

2 回答 2

3

您可以使用gproc 应用程序而不是register函数。Gproc 允许您使用任意 erlang 术语(例如字符串)作为进程别名。

于 2013-06-18T23:47:21.223 回答
2

原子永远不会被清理干净,你最终会用完原子。

json中的Pids有什么问题?你不能只用一个字符串吗?

{
    "pid": "<0.12.0>"
}
于 2013-06-18T21:48:08.653 回答