Thanks everybody for all the replies.
I've got an even smaller example by now (see below). It seems to be a problem
with the _ref counting_.
In the lines ...
result[0] = new Vector
result[1] = new Vector
... the newly created vectors do not seem have their initial _ref count_ set to
1 (which I think it should).
type
Vector = ref array[2, float64]
Matrix = ref array[2, Vector]
proc newMatrix(): Matrix =
new(result)
result[0] = new Vector
result[1] = new Vector
var m = newMatrix()
echo "m[0] ref count :", echo m[0].getRefCount()
m[0][0] = 1.0
GC_fullCollect()
m[0][0] = 2.0