Skip to content

Probable memory leak #332

@mredig

Description

@mredig

This snippet starts at line 189 in AccountStore.swift

    var listenReferenceRoom: Any?

    public func paginate(room: NIORoom, event: MXEvent) {
        let timeline = room.room.timeline(onEvent: event.eventId)
        listenReferenceRoom = timeline?.listenToEvents { event, direction, roomState in
            if direction == .backwards {
                room.add(event: event, direction: direction, roomState: roomState)
            }
            self.objectWillChange.send()
        }
        timeline?.resetPaginationAroundInitialEvent(withLimit: 40) { _ in
            self.objectWillChange.send()
        }
    }

Every time this method is called, listenReferenceRoom is overwritten with a new value and the old one is not removed from listeners. Pretty sure that's a necessary thing, but not an expert in MatrixSDK to know for sure.

Something similar happens on line 151 in the same file, but I believe that method is only called once through the lifetime of the app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions