可以跳过托儿所吗? [英] Is it possible to skip the nursery?

查看:96
本文介绍了可以跳过托儿所吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我知道某个值可能会在第一次遇到垃圾收集器时幸存下来,有没有办法让GHC知道,所以它可以直接将它分配到托儿所以外的某个地方?例如,如果我用一堆小块构建一个大型结构,我知道每件作品至少会持续到整个结构完成。

解决方案

GHC垃圾收集器对于暗示应该分配对象的世代而言,没有任何钩起。但是,您可以通过以下几种方式利用操作行为:根据数据类型,您可以根据数据类型选择不同的数据类型:


  • 能够利用固定对象区域来绕过世代阶段

  • 利用热切促销,通过确保您的长寿命对象由长期存在的东西指出...... 使数据变成 CAF 并完全绕过动态分配。



If I know a certain value is likely to survive its first encounter with the garbage collector, is there some way to let GHC know, so it can just allocate it directly somewhere outside the nursery? For instance, if I'm building up a large structure out of a bunch of smaller pieces, I know each piece will last at least until the whole structure is complete.

解决方案

In the GHC garbage collector there are no hooks for hinting at the generation an object should be allocated to. However, you might be able to exploit the operational behavior in a couple of ways:

  • depending on the data type, you may be able to exploit the pinned object region to bypass the generational stages altogether.

  • exploit eager promotion by ensuring your long lived object is pointed out by something itself long lived...

  • make the data into a CAF and bypass dynamic allocation altogether.

这篇关于可以跳过托儿所吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆