Out of Memory #190

Closed
opened 2026-04-24 23:00:42 +02:00 by adam · 10 comments
Owner

Originally created by @MisterZakary on GitHub (Jan 29, 2022).

The server is deployed using docker. The standby is normal. Once you listen to the book, the memory occupation is very high, and the web client and Android client cannot be used normally. The relevant information is shown in the picture:
Snipaste_2022-01-29_12-46-00
Snipaste_2022-01-29_12-46-16
Snipaste_2022-01-29_12-46-54

Originally created by @MisterZakary on GitHub (Jan 29, 2022). The server is deployed using docker. The standby is normal. Once you listen to the book, the memory occupation is very high, and the web client and Android client cannot be used normally. The relevant information is shown in the picture: ![Snipaste_2022-01-29_12-46-00](https://user-images.githubusercontent.com/6135863/151647809-5e8170d2-d73a-444e-af24-6fd2a4d5ea30.png) ![Snipaste_2022-01-29_12-46-16](https://user-images.githubusercontent.com/6135863/151647810-178dc026-99c7-4e75-8858-f9d7126fae7f.png) ![Snipaste_2022-01-29_12-46-54](https://user-images.githubusercontent.com/6135863/151647812-dad85677-a4be-4d9f-be95-463179ade51b.png)
adam closed this issue 2026-04-24 23:00:43 +02:00
Author
Owner

@advplyr commented on GitHub (Jan 29, 2022):

Is it the server or the web client that is out of memory?

@advplyr commented on GitHub (Jan 29, 2022): Is it the server or the web client that is out of memory?
Author
Owner

@MisterZakary commented on GitHub (Jan 30, 2022):

Is it the server or the web client that is out of memory?

Web Client.
But I personally think that the web client and Android client can not be used properly because of the server problem. When listening to audio books, Docker shows that the memory consumption of the server can be as high as 4GB.

@MisterZakary commented on GitHub (Jan 30, 2022): > Is it the server or the web client that is out of memory? Web Client. But I personally think that the web client and Android client can not be used properly because of the server problem. When listening to audio books, Docker shows that the memory consumption of the server can be as high as 4GB.
Author
Owner

@MisterZakary commented on GitHub (Jan 30, 2022):

Is it the server or the web client that is out of memory?

Maybe it's because the book (novel) is too long, it takes 334 hr and 17 min to read, and the total file size is 18GB. Please optimize the super-long audiobook.

@MisterZakary commented on GitHub (Jan 30, 2022): > Is it the server or the web client that is out of memory? Maybe it's because the book (novel) is too long, it takes 334 hr and 17 min to read, and the total file size is 18GB. Please optimize the super-long audiobook.
Author
Owner

@advplyr commented on GitHub (Jan 30, 2022):

If you can monitor the memory usage when playing other audiobooks of various sizes that would help me understand the baseline.

@advplyr commented on GitHub (Jan 30, 2022): If you can monitor the memory usage when playing other audiobooks of various sizes that would help me understand the baseline.
Author
Owner

@MisterZakary commented on GitHub (Jan 31, 2022):

This is the memory footprint in different situations:
Snipaste_2022-01-31_11-11-01
By splitting the same book into different volumes, the memory footprint is now basically acceptable. Each volume contains 100 files with a total size of 974 MB, playback duration of 34 hr and 11 min, and memory consumption between 1.5GB-2.0GB. However, the line is often disconnected during playback, and Docker looks at the log and shows [ERROR: [Server] clientEmitter-no clients found for user usr_ydsr3872gqnz8n1cnd].
log.zip

@MisterZakary commented on GitHub (Jan 31, 2022): This is the memory footprint in different situations: ![Snipaste_2022-01-31_11-11-01](https://user-images.githubusercontent.com/6135863/151734240-36499cc0-54a6-49f7-8d2f-53d64db82347.png) By splitting the same book into different volumes, the memory footprint is now basically acceptable. Each volume contains 100 files with a total size of 974 MB, playback duration of 34 hr and 11 min, and memory consumption between 1.5GB-2.0GB. However, the line is often disconnected during playback, and Docker looks at the log and shows [ERROR: [Server] clientEmitter-no clients found for user usr_ydsr3872gqnz8n1cnd]. [log.zip](https://github.com/advplyr/audiobookshelf/files/7967819/log.zip)
Author
Owner

@advplyr commented on GitHub (Feb 1, 2022):

That memory usage is way too high for what you are doing.

This may be related to the unstable socket connection you are experiencing.
From your logs it is hard to tell if the socket issues are happening with the web or mobile app. If you can try testing with just the web app that would help. Also, there was a new android app version update that should fix one of the sync issues I noticed you had in the log.

When you restart the server, without opening any clients up, what is the idle memory usage? For me it is 46MB.

If you open the web client after a restart and navigate around without playing an audiobook, do you notice any memory spikes? Try sorting, filtering or making an update.

When you first play an audiobook you should see a spike in memory usage until the transcode has finished. Once the transcode is done you should see the memory usage go back down while you are still streaming.

@advplyr commented on GitHub (Feb 1, 2022): That memory usage is _way_ too high for what you are doing. This may be related to the unstable socket connection you are experiencing. From your logs it is hard to tell if the socket issues are happening with the web or mobile app. If you can try testing with just the web app that would help. Also, there was a new android app version update that should fix one of the sync issues I noticed you had in the log. When you restart the server, without opening any clients up, what is the idle memory usage? For me it is 46MB. If you open the web client after a restart and navigate around without playing an audiobook, do you notice any memory spikes? Try sorting, filtering or making an update. When you first play an audiobook you should see a spike in memory usage until the transcode has finished. Once the transcode is done you should see the memory usage go back down while you are still streaming.
Author
Owner

@Lipown commented on GitHub (Feb 16, 2022):

Hello, any solution here? Basically I was unable to scan the library. I had 2 GB set on VM when docker runs until i set the ram to 4Gigs, oom killer killed all containers after pushing scan library button.

@Lipown commented on GitHub (Feb 16, 2022): Hello, any solution here? Basically I was unable to scan the library. I had 2 GB set on VM when docker runs until i set the ram to 4Gigs, oom killer killed all containers after pushing scan library button.
Author
Owner

@advplyr commented on GitHub (Feb 16, 2022):

I haven't identified the problem yet, not enough data. What OS are you using and are you using a remote file system for your library?
Do you have how long it took to use that memory after hitting scan? Do you have audio files that are a few GB each?

@advplyr commented on GitHub (Feb 16, 2022): I haven't identified the problem yet, not enough data. What OS are you using and are you using a remote file system for your library? Do you have how long it took to use that memory after hitting scan? Do you have audio files that are a few GB each?
Author
Owner

@newhinton commented on GitHub (Mar 9, 2022):

I have probably the same issue. I am running Audiobookshelf in docker on a Raspberry Pi 4 2GB, and the library is on an attached external drive. Scanning 100 Books eventually crashes the container.

After hitting force rescan, it starts scanning for roughly 3 minutes, then i get the first local cover set message, and roughly after 50 seconds the container shows the restart messages.

i can also see that during scanning the serverload basically skyrockets to 280 and more, and quite a lot of ffprobe processes show up. Each of those roughly uses 10mb of ram and if 200 or more show up they can easily kill a server.

Is there a way to start the docker container with more verbose logging?

Edit:

ps -C ffprobe | wc -l

peaked at 2151 instances. After that it reduced down to 80 and then the server became unresponsive. It seems it didnt crash though, adding 1GB swap seemed to catch the crashing issue, though cpu load is extremely high and ffprobe instances keep stacking up again (before dropping back to more reasonable numbers)

Edit2:

Adding 1GB swap let the scan finish. However, it basically renders the pi nearly useless and irresponsive for the duration of the scan.
It failed again and just restarts the container

@newhinton commented on GitHub (Mar 9, 2022): I have probably the same issue. I am running Audiobookshelf in docker on a Raspberry Pi 4 2GB, and the library is on an attached external drive. Scanning 100 Books eventually crashes the container. After hitting force rescan, it starts scanning for roughly 3 minutes, then i get the first local cover set message, and roughly after 50 seconds the container shows the restart messages. i can also see that during scanning the serverload basically skyrockets to 280 and more, and quite a lot of [[ffprobe]] processes show up. Each of those roughly uses 10mb of ram and if 200 or more show up they can easily kill a server. Is there a way to start the docker container with more verbose logging? Edit: `ps -C ffprobe | wc -l` peaked at 2151 instances. After that it reduced down to 80 and then the server became unresponsive. It seems it didnt crash though, adding 1GB swap seemed to catch the crashing issue, though cpu load is extremely high and ffprobe instances keep stacking up again (before dropping back to more reasonable numbers) ~~Edit2:~~ ~~Adding 1GB swap let the scan finish. However, it basically renders the pi nearly useless and irresponsive for the duration of the scan.~~ It failed again and just restarts the container
Author
Owner

@advplyr commented on GitHub (Apr 24, 2022):

Consolidating issues with the scanner and memory/performance here #444

@advplyr commented on GitHub (Apr 24, 2022): Consolidating issues with the scanner and memory/performance here #444
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#190