MaartenBaert / ssr

SimpleScreenRecorder, a screen recorder for Linux
http://www.maartenbaert.be/simplescreenrecorder/
GNU General Public License v3.0
2.58k stars 290 forks source link

Out of memory after 10+ hours of streaming #828

Open jcn50 opened 4 years ago

jcn50 commented 4 years ago

Background: I am streaming a window to YouTube, everything is fine and the memory is fine: however after 10+ hours SSR is killed by the system (OOM):

95327.384563] Out of memory: Kill process 10309 (simplescreenrec) score 675 or sacrifice child [95327.384574] Killed process 10309 (simplescreenrec) total-vm:3232156kB, anon-rss:177232kB, file-rss:0kB, shmem-rss:17168kB [95327.478200] oom_reaper: reaped process 10309 (simplescreenrec), now anon-rss:16kB, file-rss:0kB, shmem-rss:17168kB

There is nothing valuable in the SSR logs (this is the last lines):

^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Too many audio samples, dropping samples to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Too many audio samples, dropping samples to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m ^[[1;33m[Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.^[[0m

I have 512MB of physical RAM and 3GB of vSwap.

I cannot understand why it is fine for hours.. and then suddenly the memory usage just explodes?

MaartenBaert commented 4 years ago

512MB is really low if you want to do video encoding. I'm not sure though why SSR would use 3.2GB of virtual memory. It would be useful to know how much actual (anon) memory SSR was using, but the error only reports 'resident' memory (i.e. excluding swap).

What is the size of the SSR log? I'm wondering whether the messages in the log window might be using so much memory that it triggered the OOM killer.

jcn50 commented 4 years ago

I'm not sure though why SSR would use 3.2GB of virtual memory.

I wanted to know too: I have monitored SSR for a couple of hours but the RAM usage was fine. It is always crashing when I am not monitoring. I have tried another/better server and it is the same.

It would be useful to know how much actual (anon) memory SSR was using, but the error only reports 'resident' memory (i.e. excluding swap).

I would say the swap was full of SSR's usage!

What is the size of the SSR log?

The log of the last crash was 49KB. There are some other logs files up to 609KB. I have looked at those other logs and they all end abruptly like the one shown above.

If you cannot think of any cause: I will try to test on a 1GB RAM server and come back to you.

jcn50 commented 4 years ago

Hi again Marteen,

Very sorry for the late follow-up!

I have tried on a server with 1GB of RAM and I get the same, which is:

Those are the last lines in the logs: [Synchronizer::ReadAudioSamples] Warning: Too many audio samples, dropping samples to keep the audio in sync with the video. [Muxer::MuxerThread] Error: Can't write frame to muxer! [Muxer::MuxerThread] Exception 'LibavException' in muxer thread. [Synchronizer::ReadAudioSamples] Warning: Too many audio samples, dropping samples to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Too many audio samples, dropping samples to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Too many audio samples, dropping samples to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Too many audio samples, dropping samples to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Too many audio samples, dropping samples to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Too many audio samples, dropping samples to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video. [Synchronizer::ReadAudioSamples] Warning: Not enough audio samples, inserting silence to keep the audio in sync with the video.

I can only things of the options within SSR which I did not try to check/uncheck:

Or any other OpenGL errors (I don't know where the logs are?).

MaartenBaert commented 4 years ago

If you receive this error message: [Muxer::MuxerThread] Error: Can't write frame to muxer! Then you should have also received a more detailed error message from FFmpeg in stderr. If you use the latest version of SSR this message will be combined with the SSR log messages as well. Without the more detailed error message it is impossible to know what went wrong.

Try updating to the latest version of SSR, this will at least improve the error messages.

jcn50 commented 4 years ago

Try updating to the latest version of SSR, this will at least improve the error messages.

I have used the apt install simplescreenrecorder within a Debian 10 installation, wasn't that the latest version? 😢

MaartenBaert commented 4 years ago

Debian doesn't update their packages that often. If you want to get the latest version, it's best to compile it yourself. You can clone the git repository and follow the instructions in the readme file. It's not that hard, you just have to install some dependencies and then run ./simple-build-and-install.

Just make sure that you uninstall the simplescreenrecorder package from the repositories first, because otherwise you will overwrite it when you compile it yourself.

jcn50 commented 4 years ago

Debian doesn't update their packages that often.

I have just discovered this recently (for other apps!).

Do you know if Ubuntu is having your latest version in its depository?... I do not mind changing the distro.

MaartenBaert commented 4 years ago

Ubuntu has the same version as Debian, however if you use Ubuntu you can install it from my PPA (see the instructions on my website) which always has the latest version.

You may also be able to manually download the package from the PPA and install it on Debian instead, but this may result in version conflicts if you can't find a version of Ubuntu that matches the package versions of your Debian installation.