Questions about array/text GC

I’m new to this awesome project :+1:. I have a few questions about the GC mechanism.

In paper YATA “Garbage Collection” section, it says GC will be triggered after a period of time.
And GC described in the paper seems to mean the removal of a operation, not just clearing the content field.

However, I cannot find related code in yjs repo. If I insert 10000 sentences to a Y.Text and delete them afterwards,the store will still be large even if the remaining data is small. Because the store still holds the ContentDeleted/GC objects.

Am I missing something here? Or is it implemented in somewhere else?

i’m away from main pc right now, but the GC operation is located in the “cleanupTransactions” section of the source if I’m not mistaken.

Thanks. I’ve read the related code and found the following case would cause a large amount of items cannot be gc. Is this by design?

export function createArrayDoc(
  leftWordNum: number = 100,
  opNum: number = 10000,
  gc = true,
) {
  const doc = new Y.Doc({ gc });
  const text = doc.getArray('content');
  for (let i = 0; i < opNum; i++) {
    text.insert(chance.integer({ min: 0, max: text.length }), ['h', 'b', 'c']);
  }

  while (text.length > leftWordNum + 10) {
    text.delete(chance.integer({ min: 0, max: text.length - 5 }), 5);
  }

  return doc;
}