Closed unspacyar closed 10 months ago
Forgot to mention that I'm using version 1.0. Thanks !
Maybe that's the leak mentioned in the comments of #34 . I'm afraid we have to wait on a real dev to have a look at that.
Not the real dev you were asking for, but willing to take a look once in a year or so. Having no profiler in hand, I decided to start commenting portions of code until memory consumption stopped. I left outside BSoundPlayer, BMediaFile and friends in StreamPlayer.cpp, then I basically left empty all the DataReceived functions in StreamIO.cpp, but I was having no luck, until I decided not to run the BHttpRequest and bingo, it suddenly stopped.
So with the BHttpRequest running and StreamRadio doing absolutely nothing in response to that, memory comsumption keeps going higher, but not at the same rate. In my case, with the stream that I'm using, quite slowly, but obviously it depends on the bitrate. BHttpRequest never frees the memory that uses. If I stop the stream (remember, this is with no BMediaFile or BSoundPlayer in between) the memory consumption stops, but it doesn't go down, so that memory never gets freed, even when the BHttpRequest object is destructed.
That is definitely one thing to look. It must be difficult to handle because we're talking about an HTTP request that "never ends", so I'm not sure if this is expected behaviour, if we need to inform BHttpRequest "we're already done with that part" somehow or if we hit a bug. I need to run some more tests, but at some point (180mb or so) it seemed to me that memory consumption went down, so I think it might have some kind of safety switch as well (do not exceed XXmb, for example). Maybe @pulkomandy can give us a hint.
On the other hand, with the regular StreamRadio build, memory consumption is way higher, 4X as above according to my tests. It makes sense because the above build doesn't construct the BMediaFile or BSoundPlayer, doesn't decode the stream, basically it does nothing, so this one should use a little bit more, but then it's never freed so this is where our big leak is.
BHttpRequest itself does not store any data, it just calls the DataReceived function with the data and then immediately forgets about it. So I don't see how it can be leaking memory in this way.
Hi, thanks for giving me a hand here. First things first: can I trust Process Controller to tell me the real memory consumption? Cause otherwise forget about what I said.
I did a couple of tests more. I'm using a 256 kbps stream, so that's 32KB/s, or roughly 1MB every 30 seconds. Memory consumption on "standard" StreamRadio in my case is roughly 4MB every 30 seconds. I've found the offender on the DataSyncedReceived function in StreamIO.cpp:
fInputAdapter->Write(data, size);
I previously disabled the BSoundPlayer, BMediaFile, etc and nothing changed. The moment I commented this line out memory consumption went from 4MB every 30 seconds to 1MB every 30 sec, which is funnily exactly the stream size. Obviously that line is needed for StreamRadio to work, so I'll keep looking at it. That would be the "big leak" I refer on the previous comment.
At the same time, with all that disabled, DataReceived empty, etc, I still get that 1MB/30 secs, which is fine cause is reading the stream, but then it keeps adding until I stop playing. Then it stops, but consumption never goes down, so seems that memory is not getting freed somewhere.
Thanks for taking your time to help a newbie.
EDIT: seems that BInputAdapter/BAdapterIO are experimental/undocumented, part of the "new" Media Kit. Any documentation or person to refer to?
There were a number of possible memory leak issues found by Clang Static Analyser. Maybe the solution can be found in the attached report. https://github.com/HaikuArchives/StreamRadio/issues/47
Closing as fixed
Hello. I tested again, after the last update, but unfortunately the memory leaks still exists.
Between the first and the second picture, there application was running for around 1 hour: https://0x0.st/HxGf.png
Is this on nightly?
Hi. Yes, is on nightly (32 bits).
Which stream URL?
Hi. There is one that I used to test the application:
Name: 0nlineradio BEETHOVEN Stream URL: https://stream.0nlineradio.com/beethoven?ref=radiobrowser
Please check again with the last update at Haikuports. Should be better than before.
Hello. Sorry for my late answer. I had been testing and apparently the issue was fixed. Thank you!!
Hi. After leaving StreamRadio running and playing some station, the memory usage keeps growing. This is some data:
When starting playing, the memory goes around 10~12 MB. After 5 minutes of playing, the memory went to around 46 ~ 47 MB. After 2 hours, the memory usage went to 387 ~ 388 MB. After 3 hours, memory usage apparently stabilizes around 400 MB.
Stoping and starting the streaming, didn't impact the memory usage.
I'm using 32 bit version.