Closed Smiller193 closed 4 years ago
Hey @Smiller193! Have you tried any debugging using Xcode's retain cycle detection?
Umm im not exactly sure how to do that tbh but I could look into it
@rnystrom
Yup that’s a good start! Take a look at that link and you can do some googling. Lots of resources on how to debug retain cycles that can at least help pinpoint what isn’t being released.
Sent with GitHawk
Okay so I found three leaks but im not sure how I go about fixing them now.. I don't really get any useful out of them it seems @rnystrom
@Smiller193 what are the leaks?
@rnystrom according to the stack trace the leaks is in the commentSectionController and it may be coming from here
override func sizeForItem(at index: Int) -> CGSize {
let frame = CGRect(x: 0, y: 0, width: collectionContext!.containerSize.width, height: 50)
let dummyCell = CommentCell(frame: frame)
dummyCell.comment = comment
dummyCell.layoutIfNeeded()
let targetSize = CGSize(width: collectionContext!.containerSize.width, height: 55)
let estimatedSize = dummyCell.systemLayoutSizeFitting(targetSize)
let height = max(40+8+8, estimatedSize.height)
return CGSize(width: collectionContext!.containerSize.width, height: height)
}
Is there any way to show what I see in the side menu like in a picture
@rnystrom these are the leaks and each time I click one of the mallocbytes it takes me to that function that I listed earlier
The leaks on my phone and the leaks on the simulator also seem to be different. On my phone the memory goes back down when I leave the screen on my simulator it just keeps increasing
@Smiller193
Maybe you could try to use [weak self]
when you observe the change of Firebase in method fetchComments()
.
And you can also trying to log malloc stack, maybe can help you much easier to find memory issue.
Sent with GitHawk
Okay I will try that
Not applicable anymore
Through the help of everyone that contributes to this issues section I have been able to properly implement IGListKit for my comments section. I just want to start by saying thanks for that. Maybe this is an error and maybe this is not but I am using a viewController to display the cells that I use to render my comments. When I go to my viewController the memory spikes up which makes a little bit of sense. However when I leave the controller the memory never goes back down. When I go to a new controller the memory increases continously. Im trying to figure out if it is my implementation of IGListKit thats flawed or my overall logic in general because this seems like a memory leak to me. I will include my code below to see if anyone here could possibly help me.
This is my commentsController which implements the appropriate section controllers
This is the controller that is tasked with presenting the commentsController on click of a button I have only inluded the functions that contribute to presenting the controller to save time and reading.
Through opening the commentSection in various post i have seen memory go from 70 mb (When app opened) to 126 mb ( when comment section of a post is opened) 165 mb (when other comment section is closed and new comment section is opened)