uncomplicate

kenny 2025-08-15T04:17:28.024229Z

Hi. I was reading https://dragan.rocks/articles/18/Neanderthal-vs-ND4J-vol2 and saw this example. Is this use of with-release actually memory safe? e.g., if the mapping function threw part way through the list its looping over, will it safely dispose of the already looped over values? e.g., [m1, m2, ex!!!] - will m1 and m2 be released?

(defn bench-neanderthal-mm [dimensions]
  (with-release [ms (map (comp (partial fmap! random) fge)
                         (butlast dimensions) (rest dimensions))]
    (quick-bench
     (release (apply mm ms)))))

2025-08-15T17:31:42.841079Z

It should release nested sequences, too.

kenny 2025-08-15T17:58:39.055639Z

What about the case of an exception while looping over the list?

2025-08-15T19:47:49.904169Z

Please throw that exception, check whether your data has been released, and, if there's a bug, open an issue.