Kanna icon indicating copy to clipboard operation
Kanna copied to clipboard

memory leaks

Open gbuela opened this issue 7 years ago • 3 comments

Description:

I'm getting memory leaks here:

0 libsystem_malloc.dylib malloc_zone_malloc 1 libsystem_malloc.dylib malloc 2 libxml2.2.dylib xmlStrndup 3 libxml2.2.dylib xmlSplitQName 4 libxml2.2.dylib xmlSAX2StartElement 5 libxml2.2.dylib htmlParseStartTag 6 libxml2.2.dylib htmlParseContentInternal 7 libxml2.2.dylib htmlParseDocument 8 libxml2.2.dylib htmlDoRead 9 Kanna specialized libxmlXMLDocument.init(xml:url:encoding:option:) 10 Kanna specialized libxmlHTMLDocument.init(html:url:encoding:option:) 11 Kanna libxmlHTMLDocument.init(html:url:encoding:option:) /Users/.../Pods/Kanna/Sources/Kanna/Kanna.swift:0 12 Kanna libxmlHTMLDocument.__allocating_init(html:url:encoding:option:) /Users/.../Pods/Kanna/Sources/Kanna/Kanna.swift:0 13 Kanna HTML(html:encoding:option:) /Users/.../Pods/Kanna/Sources/Kanna/Kanna.swift:125

Installation method:

  • [ ] Carthage
  • [ X] CocoaPods(1.1.0 or later)
  • [ ] Swift Package Manager
  • [ ] Manually
  • [ ] other: ()

Library version:

  • [ ] v2.1.1
  • [X ] other: (2.2.1)

Xcode version:

  • [ ] 8.1 (Swift 3)
  • [ ] 8.1 (Swift 2.3)
  • [ ] 7.3.1
  • [X ] other: (9.0 Swift 3.2)

gbuela avatar Sep 20 '17 02:09 gbuela

@gbuela

Thanks for letting me know. However I can not reproduce it for now. I'd like to know more about leak situation.

  1. Does it occur even with simple HTML/XML parsing?
  2. Could you present code to reproduce?
  3. Please let us know if there is additional information.

Thanks

tid-kijyun avatar Sep 27 '17 08:09 tid-kijyun

I realize this is an old issue at this point, but I am experiencing this as well with 5.2.7. It happens for me after calling htmlDocument.body?.removeChild(childElement).

It seems removeChild doesn't fully cleanup the libxml2 memory. Possibly it should call xmlFreeNode instead of xmlFree?

bfichter avatar Nov 30 '21 21:11 bfichter

@bfichter You're right. Thanks for the helpful advice!

tid-kijyun avatar Dec 01 '21 03:12 tid-kijyun