Closed dsanghan closed 7 years ago
When you do a simple doc.body, the document gets retained by the iterator in root and referenceNode and the iterator gets retained by the document in attachNodeIterator - hence neither gets deallocated.
root
referenceNode
attachNodeIterator
- (instancetype)initWithNode:(HTMLNode *)node showOptions:(HTMLNodeFilterShowOptions)showOptions filter:(id<HTMLNodeFilter>)filter { self = [super init]; if (self) { _root = node; // retains doc _filter = filter; // retains doc _whatToShow = showOptions; _referenceNode = _root; _pointerBeforeReferenceNode = YES; [_root.ownerDocument attachNodeIterator:self]; // doc retains iterator } return self; }
A possible fix is to convert the nodeIterator array into a weak objects NSHashTable.
nodeIterator
NSHashTable
@dsanghan Hey, good catch 👍 Thanks for reporting.
The same bug affects HTMLRange. I'll open a new issue for those.
HTMLRange
Fixed in 2.0.2
When you do a simple doc.body, the document gets retained by the iterator in
root
andreferenceNode
and the iterator gets retained by the document inattachNodeIterator
- hence neither gets deallocated.A possible fix is to convert the
nodeIterator
array into a weak objectsNSHashTable
.