Memory usage

  • Hello Marcel and everybody.


    I have a question related to the memory consumption of the DICOM server. Is it common for the server to use over 1 GB of memory in the idle state?
    I am running Debian 8 (kernel version 4.9.2-2~bpo8+1), server version 1.4.17d with MySQL.


  • Hi,


    I am not aware of any leaks in 1.4.17d, and I would expect memory use of ~20MB. Of course when you transmit large objects these are loaded into memory temporarily (an a few of them because of the read-ahead thread), so maximum memory usage of that amount would not be strange. What does pmap report? Is the memory use stable, or does it slowly rise?


    Marcel

  • Hello Marcel,


    thank you for your replay. After some more testing it looks the problem was in my ExportConverter where I use dcmtk and other tools to postprocess the data. When I commented it out the memory use is pretty low and stable. Thank you for your time, I should have tried it already before.

  • The exportconverter string is simple:

    Code
    ExportConverters = 1
    ExportConverter0 = 'postprocess.sh "%f"'


    Longer story: I have created a docker container with the server, based on Debian image (the host machine is also running Debian), all worked well but I have observed that the container is growing and never shrinking (or shrinking just some megabytes but not more), the biggest container size I have seen until now was over 2 GB, after I have restarted it. In the container is running only the dgate server, when I execute "pmap" in the container with the PID of the dgate server, it corresponds with the container size as Docker shows.


    I have found out that in my script for post-processing I have called dcmdump (which by default processed all the data, see +M option). When I tried to use -M, the memory foot print looks better right now... but it is probably just about making the symptoms smaller:

    Quote


    +M --load-all load very long tag values (default)
    -M --load-short do not load very long values (e.g. pixel data)

  • There is only one process running in the container. PID 1 belongs to a bash script which makes sure that log and data directories are created and starts dgate -p5600 -^/dgate/logs/serverstatus.log

  • Marcel, maybe it is Docker related. The container have memory usage about 2.3 GiB. I tried to find some more info about the memory, here is a memory stat from the docker. I see cache and inactive_file are pretty high:



    https://docs.docker.com/engine…memory-metrics-memorystat

  • Hi,


    it does seem every thread has a big stack (the two threads are likely related to exportconverters and import monitor), so the way threads are started may not be optimal under linux, this is a typical example:


    Code
    pthread_t ThreadID;
    pthread_create(&ThreadID, NULL, (void*(*)(void*))monitorthread, (void *)global_folder);
    pthread_detach(ThreadID);


    Marcel

  • Not really,


    but of course every thread that starts needs at least 320 MB. So the peak memory use could be about 1.2GB when data is being sent (main thread, converters, import thread and read ahead thread). It is up to the OS to release that memory when no longer needed. Not sure how that woeks in docker.


    Marcel

  • I have found out that Docker provides settings called "memory reservation". This might help to reclaim the memory when it is not needed anymore:

    Quote


    The container can use as much memory as it needs. The memory reservation setting ensures the container doesn’t consume too much memory for long time, because every memory reclaim shrinks the container’s consumption to the reservation.


    https://docs.docker.com/engine…/#user-memory-constraints


    Marcel, thank you for your insight.

  • Update: I have added "memory reservation" for 100 MB and it looks very good now: when the server needs memory, container grows, after it shrinks down to 100 MB. Before it was just growing and growing...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!