SwiftSoup: `siblingElements()` returns empty collection when build in release mode
i’ve tried removing optimization levels for release for SwiftSoup but doesn’t help.
the code:
elements = try document.select(".frontPageWidget tr").first()?.siblingElements()
in both debug and release mode the .first()
element is the same and not nil, but only in debug mode i can grab the siblings. in release mode i get nothing.
just a few months old in Swift/Xcode so it’s probably on my side. i’ve built a library that i use along SwiftSoup and it works fine. but i can’t figure out that last one. any idea what am i be doing wrong? thanks!
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 20 (6 by maintainers)
Found the bug, parent Node in SwiftSoup is in weak, weak var parentNode: Node? otherwise we will have a memory leak because parent have an array with all childs.
If you call
document.select(".frontPageWidget tr").first()?.siblingElements()
more time only he last will have zero elements.document should be put in a variable and set to nil only after use is finished, if it is freed all the elements not retained in memory will be removed.
I’ll think of a solution.
@godbout can you provide an HTML to test it? Thank you