You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 17, 2021. It is now read-only.
Hi! I've noticed a memory leak when using CommonMark.Document "standalone" as root node, basically the first example that is given in the README file (just initialize a new Document with a commonmark string).
It seems that for this initializer the internal managed property would not be set to true, and then prevent the cmark nodes from being freed in deinit.
To fix that, I just added an extension that would set the managed property, sth. like this (I'm sure there are better ways...):
public extension Document {
// Enforce managed flag to be set when the node is used "standalone", otherwise no freeing of cmark nodes will happen on deinit.
class func root(_ commonmark: String, options: ParsingOptions = []) throws -> Document {
let document = try Self.init(commonmark, options: options)
document.managed = true
return document
}
}
Can you confirm this or am I missing sth. in terms of the API or intended usage?