SongKong and Jaikoz Music Tagger Community Forum

Songkong QNAP Docker Container - SongKong is short of memory, task has to be cancelled to prevent further problems Java heap space

Paul,

I recently ran the Songkong fixsongs function on my unmatched music folder and received the following error:

" SongKong is short of memory, task has to be cancelled to prevent further problems Java heap space

Im running the songkong docker container with the following docker create code:

sudo docker create --name songkong \
--privileged \
--ulimit nofile=262144:262144 \
--restart=always \
--net=lsio \
-e PUID=0 \
-e PGID=0 \
-e TZ="America/New_York" \
-p 4567:4567 \
-v "/share/appdata/songkong":/config \
-v "/share/music/Music":/music \
-v "/share/music/library":/library \
songkong/songkong

How do i resolve the above error? To the best of my knowledge java is not running as a docker container. Its an app that is installed on the QNAP that runs.

PS: I uploaded support files for this issue.

Robert

Java is required by SongKong and is installed and runs as part of the SongKong Docker Image.

SongKong is designed to run on multiple folders at once, and should need little more memory than is required to process the folders it is actively processing. So for example if you had 200 albums each in its own folder, and your PC had four cpus it should just be processing 4 folders in parallel and have enough memory to process those four folders.

If you have all your files in a single folder then that can be problematic and causes SongKong to use more memory but I don’t think that is your situation.

On the desktop version of SongKong you can see current memory used / max memory allowed

memory

but that is not shown on web UI.

But if you look at songkonguser0-0.log in your SongKong config folder you can see how much memory is allocated at start up, and for Dockers it is set to just 800mb.

i.e

23/01/2020 22.19.16:EST:WARNING: SongKong 6.7.3 Closer 1110 16/12/2019 using Java 1.8.0_212 25.212-b04 64bit on Linux 4.14.24-qnap amd64 initialized successfully
23/01/2020 22.19.16:EST:WARNING: No of CPUs:4
23/01/2020 22.19.16:EST:WARNING: SongKong has been configured with minimum heap memory of 150 mb, maximum heap memory of 800 mb and maximum permanent memory of -32 mb
23/01/2020 22.19.16:EST:WARNING: Total Computer Memory is 64,298 mb

The SongKong Docker file used to create the SongKong image can be found at https://bitbucket.org/ijabz/songkongdocker/src/master/Dockerfile

FROM openjdk:8-jre-alpine

    RUN apk --no-cache add \
          ca-certificates \
          curl \
          fontconfig \
          msttcorefonts-installer \
          tini \
     && update-ms-fonts \
     && fc-cache -f
        
    RUN mkdir -p /opt \
     && curl http://www.jthink.net/songkong/downloads/current/songkong-linux-docker.tgz?val=112 | tar -C /opt -xzf - \
    && find /opt/songkong -perm /u+x -type f -print0 | xargs -0 chmod a+x

    EXPOSE 4567

    ENTRYPOINT ["/sbin/tini"]

    # Config, License, Logs, Reports and Internal Database
    VOLUME /songkong

    # Music folder should be mounted here
    VOLUME /music

    WORKDIR /opt/songkong

    CMD /opt/songkong/songkongremote8.sh

Max memory is set in songkongremote8.sh which currently contains

java -Xms150m -Xmx900m -Dcom.mchange.v2.log.MLog=com.mchange.v2.log.jdk14logging.Jdk14MLog -Dorg.jboss.logging.provider=jdk -Djava.util.logging.config.class=com.jthink.songkong.logging.StandardLogging -jar lib/songkong-6.7.jar -r

(Note this is a restriction of Java, it cannot automatically just use all the memory available on your computer, you have to preallocate the max memory it can use, this is not the same as the max memory it will use)

You should not usually have to increase the amount of memory available, but if you are getting a memory problem and you have additional memory available then it that might be an idea to increase it. The question is how you modify for a docker image without having to create your own docker image, that is something I need to research tomorrow…

Seems possible solution is at https://success.docker.com/article/java-app-is-killed-by-docker I will look into this.

Paul,

I have additional memory available on my QNAP. How can i increase the java heap size without having to create a unique docker image of songkong?

Based on the article: https://success.docker.com/article/java-app-is-killed-by-docker

Root Cause

By default java application will use 1/4 of the host memory, not the container. This is the default definition of java running without options outside of the containers. The rest of the memory is used for swap, caching, …

Is their any way i can add an environmental variable with options to my docker create code for songkong to increase the max java heap size?

Robert

What I am planing to do is recreate the docker container so it automatically makes use of the memory limits defined for the container, and make this the standard. Then this should work for you and everyone else, but I havent had time to do it so far today.

Added https://jthink.atlassian.net/projects/SONGKONG/issues/SONGKONG-1960

Hi, I have now replaced the Docker image, if you remove old one and reinstall the new one should allocate about half of whatever the memory allocated to the container as heap memory.

i.e. tested on a Synology DS218+ with 2GB of ram

If you create container without configuring any memory limitations

and then check the songkong-user0-0.log file under the foldr configured as /songkong folder it sets max memory of 885mb. On a server with more than 2GB of ram I expect this would be more.

28/01/2020 14.22.47:GMT:WARNING: SongKong 6.7.3 Closer 1110 16/12/2019 using Java 1.8.0_212 25.212-b04 64bit on Linux 4.4.59+ amd64 initialized successfully
28/01/2020 14.22.47:GMT:WARNING: No of CPUs:1
28/01/2020 14.22.47:GMT:WARNING: SongKong has been configured with minimum heap memory of 30 mb, maximum heap memory of 885 mb and maximum permanent memory of -32 mb
28/01/2020 14.22.47:GMT:WARNING: Total Computer Memory is 1,828 mb

When I checked Enable Resource Limitation and set Memory Limit to max it set max heap to 989mb

28/01/2020 14.27.30:GMT:WARNING: SongKong has been configured with minimum heap memory of 32 mb, maximum heap memory of 989 mb and maximum permanent memory of -32 mb
28/01/2020 14.27.30:GMT:WARNING: Total Computer Memory is 1,828 mb

When I checked Enable Resource Limitation and set Memory Limit to 608mb it set max heap to 293mb

28/01/2020 14.30.04:GMT:WARNING: SongKong has been configured with minimum heap memory of 10 mb, maximum heap memory of 293 mb and maximum permanent memory of -32 mb
28/01/2020 14.30.04:GMT:WARNING: Total Computer Memory is 1,828 mb

So on your server which has substantially more memory it should allocate upto half to SongKong (depending on whether you set a memory limit or just use defaults for container). This should hopefully avoid the memory issue but we cannot be sure of this because do not know what the underlying cause of the OutOfMemory exception is.