Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak: GMGridView never gets deallocated #32

Merged
merged 1 commit into from
Jan 27, 2012
Merged

Memory Leak: GMGridView never gets deallocated #32

merged 1 commit into from
Jan 27, 2012

Conversation

soleares
Copy link
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 added a commit that referenced this pull request Jan 27, 2012
Memory Leak: retain cycle
@gmoledina gmoledina merged commit c65fb44 into gmoledina:master Jan 27, 2012
@gmoledina
Copy link
Owner

Good catch! Thank you.

@majinbigor
Copy link

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
Copy link
Contributor Author

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.

@majinbigor
Copy link

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
Copy link
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.

@steipete
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants