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 may occur #9

Open
zhuofeng6 opened this issue Mar 5, 2023 · 0 comments
Open

memory leak may occur #9

zhuofeng6 opened this issue Mar 5, 2023 · 0 comments

Comments

@zhuofeng6
Copy link

zhuofeng6 commented Mar 5, 2023

Is there something wrong with this code? Object.connections_smobjs[self.connection] = \

One firewall corresponds to one connection. Therefore, there is only one connection. So it go in if self.connection not in Object.connections_senders the first time, and never get in again. This code (Object.connections_smobjs[self.connection] = \ )should not be indented.

If indented, then connections_senders will only increase and never remove. The memory will leak this way. Am i right?

Because we encountered a memory leak on firewalld, the final location is this indentation caused. I look forward to your reply, although you don't maintain slip anymore

    def sender_seen(self, sender):
        if (sender, self.connection) not in Object.senders:
            Object.senders.add((sender, self.connection))
            if self.connection not in Object.connections_senders:
                Object.connections_senders[self.connection] = set()
                Object.connections_smobjs[self.connection] = \
                    self.connection.add_signal_receiver(
                        handler_function=self._name_owner_changed,
                        signal_name='NameOwnerChanged',
                        dbus_interface='org.freedesktop.DBus',
                        arg1=sender)
            Object.connections_senders[self.connection].add(sender)

maybe it is correct

    def sender_seen(self, sender):
        if (sender, self.connection) not in Object.senders:
            Object.senders.add((sender, self.connection))
            if self.connection not in Object.connections_senders:
                Object.connections_senders[self.connection] = set()
            Object.connections_smobjs[self.connection] = \
                self.connection.add_signal_receiver(
                    handler_function=self._name_owner_changed,
                    signal_name='NameOwnerChanged',
                    dbus_interface='org.freedesktop.DBus',
                    arg1=sender)
            Object.connections_senders[self.connection].add(sender)
@zhuofeng6 zhuofeng6 changed the title Is there something wrong with this code? memory leak may occur Mar 5, 2023
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

No branches or pull requests

1 participant