堆外的指针
Pointers outside the heap
OCaml 用户手册 4.11 版指出:
20.2.3 Pointers outside the heap
In earlier versions of OCaml, it was possible to use word-aligned pointers to addresses outside the heap as OCaml values, just by casting the pointer to type value. Starting with OCaml 4.11, this usage is deprecated and will stop being supported in OCaml 5.00.
停止支持是什么意思?性能损失?警告?程序崩溃?
我的应用程序有很多常量数据。 手.
为了帮助减少主要的 GC 成本,我正在考虑将所述数据从 OCaml 堆中深度复制到我自己的一些 grow-only/never-collected 内存中,由大页面支持。 (数据在编译时不是常量,但一旦程序启动。)
以上是否意味着我的方法将不再适用于未来的 OCaml 版本?
使用 out-of-heap 指针(指向格式不正确的 OCaml 值)的程序在编译器的 no-naked-pointer 模式下崩溃。多核 OCaml 将仅支持此 no-naked 指针模式。
引用手册:
A correct way to manipulate pointers to out-of-heap blocks from OCaml is to store those pointers in OCaml blocks with tag Abstract_tag or Custom_tag, then use the blocks as the OCaml values.
OCaml 用户手册 4.11 版指出:
20.2.3 Pointers outside the heap
In earlier versions of OCaml, it was possible to use word-aligned pointers to addresses outside the heap as OCaml values, just by casting the pointer to type value. Starting with OCaml 4.11, this usage is deprecated and will stop being supported in OCaml 5.00.
停止支持是什么意思?性能损失?警告?程序崩溃?
我的应用程序有很多常量数据。 手.
为了帮助减少主要的 GC 成本,我正在考虑将所述数据从 OCaml 堆中深度复制到我自己的一些 grow-only/never-collected 内存中,由大页面支持。 (数据在编译时不是常量,但一旦程序启动。)
以上是否意味着我的方法将不再适用于未来的 OCaml 版本?
使用 out-of-heap 指针(指向格式不正确的 OCaml 值)的程序在编译器的 no-naked-pointer 模式下崩溃。多核 OCaml 将仅支持此 no-naked 指针模式。
引用手册:
A correct way to manipulate pointers to out-of-heap blocks from OCaml is to store those pointers in OCaml blocks with tag Abstract_tag or Custom_tag, then use the blocks as the OCaml values.