JeffHoogland / qAndora

Pandora player written in Python and QT that uses VLC as a streaming backend
Other
16 stars 2 forks source link

Memory leak #15

Open JasonLG1979 opened 9 years ago

JasonLG1979 commented 9 years ago

qAndora spawns new threads for each new song and RAM usage gets crazy after a while. After listening for a few hours it was 60+ threads strong and RAM usage was over 100MB. It's got to be in the VLCplayer or VLC.py it's self. I wrote a tkinter UI and it exhibits the same behavior. So I know it's not Pyside/Qt. I'm definitely not an expert on the VLC bindings but from the looks of things a new player is created every time the song changes if so it seems that the old instance is not properly destroyed? tkdora

JeffHoogland commented 9 years ago

That is in fact what is happening. VLC python docs are here -> https://www.olivieraubert.net/vlc/python-ctypes/doc/

I don't see a delete function though for the player class.

JasonLG1979 commented 9 years ago

I've been browsing those for a couple days. There's a release function but as soon as you hit it, it locks up the player. there's got to be a way to only have one instance running and just add url's to it's playlist.

JeffHoogland commented 9 years ago

Yea - I was never able to get the API to add songs to an existing player,

JasonLG1979 commented 9 years ago

We'll figure it out. It's got to be in there somewhere.

JasonLG1979 commented 9 years ago

Maybe something along these lines? https://forum.videolan.org/viewtopic.php?t=90233

JeffHoogland commented 9 years ago

Does that support appending more files later?

JasonLG1979 commented 9 years ago

Switching back to the gstreamer backend and adding a bus to detect the eos signal until I can figure out the vlc bindings. Everything I've tried so far has awesomely failed...

JasonLG1979 commented 9 years ago

Found out how to kill the old player. It was in fact "release."

It basically works like this. I attached another callback to the end reached event that invokes "release" then "nextSong" from the mainloop. Now it never goes over 5 threads. Next up is to try to tame the RAM usage. It seems to go up a megabyte or 2 everytime the song changes. Maybe it's not clearing the song out of memory? When I get that figured out I'll do a merge request.

JeffHoogland commented 9 years ago

Sounds good. I'm going to be fairly quiet the next couple of weeks as quarter where I teach is coming to an end. Will be reading/reviewing anything you post.

JasonLG1979 commented 9 years ago

That's cool gotta pay those bills,lol!!! It'll give me a chance to do some tweaking.

JasonLG1979 commented 9 years ago

The memory leak is in the list created in addSongs and in nextSong. Even if everything is disabled and all you do is retrieve a playlist and cycle through the song index without even actually loading anything, RAM usage increases by pretty much exactly the amount as the data(album art, mp4 audio file, etc) that would have been loaded if everything weren't disabled. And it's never garbage collected. You would expect that the list would be a reference to the objects not the actual objects themselves.