swift - NSOutlineView leaks memory. What to do? -
when minimal osx application has nothing else plain (unconfigured) nsoutlineview
in storyboard, heavily leak memory.
view controller implementation
the view controller implemented following:
import cocoa class section { let title: string let items: [string] init(title: string, items: [string]) { self.title = title self.items = items } } class viewcontroller: nsviewcontroller, nsoutlineviewdatasource, nsoutlineviewdelegate { //mark: nsoutlineviewdatasource let items = [ section(title: "alpha", items: ["anton", "anita"]), section(title: "beta", items: ["bernd", "barbara"]), section(title: "gamma", items: ["gustav", "gesine"])] func outlineview(outlineview: nsoutlineview, numberofchildrenofitem item: anyobject?) -> int { switch item { case nil: return items.count case section: return (item as! section).items.count default: return 0 } } func outlineview(outlineview: nsoutlineview, child index: int, ofitem item: anyobject?) -> anyobject { return item == nil ? items[index] : (item as! section).items[index] } func outlineview(outlineview: nsoutlineview, isitemexpandable item: anyobject) -> bool { return item section } func outlineview(outlineview: nsoutlineview, objectvaluefortablecolumn tablecolumn: nstablecolumn?, byitem item: anyobject?) -> anyobject? { return item } //mark: nsoutlineviewdelegate func outlineview(outlineview: nsoutlineview, viewfortablecolumn tablecolumn: nstablecolumn?, item: anyobject) -> nsview? { let view = outlineview.makeviewwithidentifier(item section ? "headercell" : "datacell", owner: self) as! nstablecellview view.textfield?.stringvalue = item section ? (item as! section).title : item as! string return view } }
the xcode project can cloned github
xcode showing increasing memory consumption
when app started , tree items selected clicking them, memory consumption increases tremendously.
xcode's debug navigator shows increasing memory consumption on short time. memory increases when navigate through nsoutlineview nodes.
instruments not showing suspicious (or it?)
instruments showing constant memory usage, neither increasing nor decreasing:
what can conclude instrument's report? not detecting leaks because it's nsoutlineview
leaking (and can't detected?) or there no leak @ end?
Comments
Post a Comment