Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Memory Leak: GMGridView never gets deallocated #32

merged 1 commit into from Jan 27, 2012


None yet
6 participants

soleares commented Jan 27, 2012

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 added a commit that referenced this pull request Jan 27, 2012

@gmoledina gmoledina Merge pull request #32 from soleares/master
Memory Leak: retain cycle

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


gmoledina commented Jan 27, 2012

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.


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:

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?


gmoledina commented Feb 3, 2012

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.


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