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 when recreating Player on loop in Python #335

Open
Architector4 opened this issue Jun 14, 2024 · 0 comments
Open

Memory leak when recreating Player on loop in Python #335

Architector4 opened this issue Jun 14, 2024 · 0 comments
Assignees
Labels

Comments

@Architector4
Copy link

I have a Python script that I have running once a second, which uses Playerctl to fetch data about currently running players.

The only way I found to do so is to create a new Player for each player name from list_players(), because PlayerManager doesn't get information about newly appearing or closing players unless I recreate it in loop too. But this occupies more and more memory each time, even if invoke Python's garbage collector after each loop.

Same issue seems to occur even if I preserve

My script and the problem could be boiled down to this:

import gi
gi.require_version('Playerctl', '2.0')
from gi.repository import Playerctl

while True:
    for name in Playerctl.list_players():
        player = Playerctl.Player.new_from_name(name)
        #print(player.get_title())

Running this slowly drains more and more system memory. I may be missing a better way about this though, but I'm unsure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants