[Oberon] Array Index Out Of Range in ORG.FindPtrFlds
Andreas Pirklbauer
andreas_pirklbauer at yahoo.com
Sat Oct 23 21:59:39 CEST 2021
> Ich bin mir nicht ganz sicher, aber sollte es nicht so heissen? >
> > ELSIF typ.form = ORB.Array THEN FindPtrFlds(typ.base, off, dcw) END
Nope. You need *all* pointer locations across *all* array elements .. otherwise the garbage collector will not find find all pointer locations.
So for an array of N=3 records with pointer offsets 3, 37, 62 within each record, and a record size of S = 100 bytes, one needs the offsets 3, 37, 62, 103, 137, 162, 203, 237, 262. Obviously, for large arrays the number of pointer locations can quickly exceed the value of ORG.maxTD.
One way to avoid storing the *same* offsets *N times* would be to store them in compact form, for example as [N = 3, S = 100, 3, 37, 62]. But then one also needs to adapt Kernel.Mark so it can interpret this format. Due to the possibility of recursive data structures, this is complex. Been there. Doable. But not recommendable..
PS: An alternative is to extend the intrinsic procedure NEW to allow NEW(p), where p is an array of pointers. That’s what I use in Extended Oberon. In the PO 2013 2013 version I have found no better solution than to (temporarily) increase ORG.maxTD :-(
More information about the Oberon
mailing list