robb / Cartography

A declarative Auto Layout DSL for Swift :iphone::triangular_ruler:
Other
7.35k stars 525 forks source link

ConstraintGroup - Memory Leak #248

Closed mrcoolbiz closed 6 years ago

mrcoolbiz commented 7 years ago

i make a constraint group. So I can replace them with other constrain later. But after create group, the instruments just notice about ConstraintGroup has constraints with error: _ContiguousArrayStorage

Even I try to remove contraint in viewDidDisappear by your function constrain(clear: ...) and also, by remove all constraints by view.removeConstraints(view.constraints)

My code: class MainController: BaseController {

let news        = UITableView()
var navBar      : UIView!
var navGroup    : ConstraintGroup? = ConstraintGroup()

....

func drawNavBar() { navBar = UIView(frame: .zero) navBar.backgroundColor = themes[mTheme]?.tone view.addSubview(navBar)

    let menuBtn                 = UIButton(frame: .zero)
    menuBtn.setImage(UIImage.ionicon(with: .androidMoreVertical, textColor: .white, size: CGSize(width: 40, height: 40)), for: .normal)
    menuBtn.addTarget(self, action: #selector(menuBtnPressed), for: .touchUpInside)
    navBar.addSubview(menuBtn)

    constrain(navBar, menuBtn, view) { navBar, menuBtn, view in
        menuBtn.right   == navBar.right - 8
        menuBtn.top     == navBar.top + 20

        navBar.left     == view.left
        navBar.right    == view.right
        navBar.height   == 80
    }

    constrain(navBar, view, replace: navGroup) { navBar, view in
        navBar.top      == view.top
    }
mrcoolbiz commented 7 years ago

Any update for this bug ? I still can't fix this memory leak.

orta commented 7 years ago

Nope, you want to try fix it?

micromanc3r commented 6 years ago

@mrcoolbiz Are you sure about that leak? Can you post a screenshot of Instruments session? I tried to setup a minimal app to reproduce the problem based on your description in my fork...can you look at it and suggest changes to create a leak? (it's in a fix/memory_leak branch)

mrcoolbiz commented 6 years ago

I made this for long time ago. But I think this leak was solved in new updated version. You can try to test again.

micromanc3r commented 6 years ago

should this be closed then?