- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每当我使用 spawn(Mod, Func, Arguments)
时,所有参数都会被复制。如果在 Erlang 中一切都是不可变的,为什么要复制它们?为什么不只复制指针?是因为这让垃圾收集变得更加复杂吗?
最佳答案
目前,Erlang VM 维护着一个 separate heap per process *。这意味着一个进程可以独立于其他进程收集它的垃圾,使 Erlang 比保持全局堆的运行时更不容易受到 GC 暂停的影响。
为了使其有效,必须没有进程引用在另一个进程的堆上分配的内存。 大概,复制发送到 spawn/3
的参数的原因是为了将它们移动到新生成的进程的堆中。顺便说一下,这同样适用于发送到进程的消息(来源:参见上面的链接):
All data in messages between Erlang processes is copied, with the exception of refc binaries on the same Erlang node.
(*) 您可能喜欢阅读 this blog post关于 Erlang 中的垃圾回收。它实际上比我一开始所说的要复杂一些,因为一些对象(特别是原子和大型双星)是分开处理的。
Robert Virding 在下面的评论中添加了以下内容:
Having separate heaps for each process make the GC simpler and more efficient, you can reclaim much more memory in each pass than with a real-time collector. Also it scales much better in a parallel system as there are much much fewer locks and less synchronisation, which kills speed. It can also give better locality of memory and cache performance. It's one of those things which sounds worse but ends up being better.
关于erlang - 为什么刷怪会打副本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28801971/
我有一个带有 UIPageViewController 的应用程序是这样设置的: UINavigationController *navController = (UINavigationContro
我有一个用于边框背景的 MVVM 绑定(bind),其中我从字符串格式的文件中读取颜色名称,并使用代码将它们转换为画笔: Brush b1 = new SolidColorBrush((Color)C
我有一个 D3 堆积面积图,我正在尝试重新计算刷牙时的 Y 轴。问题是,当我重新计算 Y 轴的最大值时,它不是所有不同层的组合,它只是最后一层。例如,如果我同时刷了 1/17 和 1/20 日期,我将
当程序上传到STM32F4时,有没有办法用计算机信息更新RTC?例如,电脑上的日期和小时信息是:12h40 11/09/2018,当我用IAR/AC6刷微 Controller 时,RTC是用这些信息
我是一名优秀的程序员,十分优秀!