Memory Leak: GMGridView never gets deallocated #32

Merged
merged 1 commit into from Jan 27, 2012

Projects

None yet

6 participants

Contributor

GMGridView never gets deallocated because of a retain cycle with GMGridViewCell.

If you repeatedly push/pop it with a UINavigationController it will never dealloc and the memory usage increases as more GMGridView (and related) objects get alloced.

It's due to a reference to self in the cell.deleteBlock in newItemSubViewForPosition:. Updating to weakSelf fixes it.

So happy to have this resolved...

@gmoledina gmoledina merged commit c65fb44 into gmoledina:master Jan 27, 2012
Owner

Good catch! Thank you.

您好!请问我将一个view赋给cell.contentView (cell.contentView = aView),我的View上有个button,但是当我点击button时,并没有响应?

this has not worked for me...suggest some way to fix this issue

not working for me. I've have the same problem. I put in each cell, a UIImageView, but when i repeatedly push/pop it from UiNavigationController, memory remain allocated.

Contributor
soleares commented Feb 2, 2012

I'm not able to reproduce the issue using the latest GMGridView code using ARC with iOS 4.3 and iOS 5.

I created a sample project that you can use as a starting point to isolate the issue. It's a simple UINavigationController that pushes/pops one of the view controllers from the GMGridView example project:
https://github.com/soleares/GMGridViewMemoryTest

Here's what I recommend:

  1. Run the sample in Instruments with the Allocations instrument and verify that the GMGridView (and related objects) is deallocating. You should see the '# Living' column increase to 1 when you push, and the object should go away when you pop.
  2. Slowly add in any custom code from your project and see if/when the issue occurs.

Hope that helps.

i've tried your project and work perfectly. in my project, after that i pop uiviewcontroller, the GMGridView and his Cell grid remain in memory. The ARC does not even use, because it is a project started long ago and very large. could be the problem?

Owner

Thanks for the nice sample project @soleares

@majinbigor , yeah it's probably your project that is not ARC enabled. Try this in Xcode (before adding the grid classes) : Edit > Refactor > Convert to Objective C ARC.

Contributor
steipete commented Feb 8, 2012

Is this still a bug in devel? We really should remove this branch and just use main, it's way to confusing otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment