•memory — Memory
•memory x gives a record of what this thread holds, and of what x keeps alive. •memory 0 is the usual spelling for the counts alone.
recordscounts the live record nodes: the linear calls that reverse mode records while∂runs. Each∂frees its record when it returns, so the count is 0 between programs.pendingcounts the live pending arrays, whose items wait for their first read.bytescounts the bytes thatxkeeps alive: its items, the base of a view, the arrays that a pending array reads, the parts of a value that∂is differentiating, and the nodes of a record. An allocation thatxreaches twice counts once.
records and pending count the nodes that this thread made, even when another thread holds one. •memory reads no items, so it never forces a pending array, and it accepts values that ∂ is differentiating.
{+/⍵×⍵}∂ 1 2 3 ⍝ 2 4 6
•memory 0 ⍝ ["records":0ₓ "pending":0ₓ "bytes":0ₓ]A reshape is a view, which keeps all of its base’s items alive:
v←⍳1000ₓ
m←2 500⍴v
(•memory m).bytes ⍝ 2000ₓ•explain reports what happened while an expression ran.