OCaml - array of arrays and garbage collection

I know that a float array

is represented at runtime as a c block double_array_tag

and an unboxed float, so the garbage collector won't scan it (because double_array_tag >= no_scan_tag


But what about int array

? How is OCaml garbage collector unable to scan its fields?


source to share

1 answer

If I understand correctly, the garbage collector scans the fields int array

. For each field, in turn, he will notice that he is unpacked and does not chase him further.

This behavior may not be very effective; the main aspect is that it is safe. This would not be safe float array

unless each individual float

was boxed (which in turn would be area inefficient).

If the above (temporary) inefficiency is a problem, the module Bigarray

can provide a solution.



All Articles