Is it possible to skip the nursery?

跟風遠走 提交于 2019-12-20 09:34:39

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/27630833/is-it-possible-to-skip-the-nursery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!