Minidlna memory exhausted problem

Issue #239 closed
Gabor Jeney created an issue

First of all many thanks for your enormous efforts on building this great firmware! Congratulations! I really enjoy it and I hope you will continue to support and develop this firmware in the long run.

I have 2022.5 K26ARM USB AIO-64K running on Asus RT-AC66U B1, but I assume it could appear on any hardware.

Used / Total RAM 58.98 MB / 249.59 MB (23.63%)
Used / Total NVRAM 41.99 KB / 64.00 KB (65.61%)

The minidlna suffers from memory exhaustion when rebuilding the database.

I have an average size Media library:

Audio files 16572
Video files 3327
Image files 15490

When I use the built-in FreshTomato minidlna application to rebuild its database (either on GUI, or in CLI with the -R switch), it hangs (runs but does not respond to any requests). In debug mode (-d switch) I see a few media reported as failed, something like:

[2022/08/07 22:05:54] scanner.c:745: warn: Scanning /tmp/mnt/[WHATEVER0]

[2022/08/07 22:08:54] metadata.c:715: warn: Opening /tmp/mnt/[WHATEVER1].mkv failed! [Cannot allocate memory]

[2022/08/07 22:08:54] scanner.c:521: warn: Unsuccessful getting details for /tmp/mnt/[WHATEVER1].mkv

[2022/08/07 22:11:58] metadata.c:715: warn: Opening /tmp/mnt/[WHATEVER2] failed! [Invalid data found when processing input]

[2022/08/07 22:11:58] scanner.c:521: warn: Unsuccessful getting details for /tmp/mnt/[WHATEVER2].mkv

[2022/08/07 22:14:47] metadata.c:715: warn: Opening /tmp/mnt/[WHATEVER3].mkv failed! [Cannot allocate memory]

[2022/08/07 22:14:47] scanner.c:521: warn: Unsuccessful getting details for /tmp/mnt/[WHATEVER3].mkv

[2022/08/07 22:15:36] metadata.c:715: warn: Opening /tmp/mnt/[WHATEVER4].mkv failed! [Cannot allocate memory]

[2022/08/07 22:15:36] scanner.c:521: warn: Unsuccessful getting details for /tmp/mnt/[WHATEVER4].mkv

[2022/08/07 22:15:36] metadata.c:715: warn: Opening /tmp/mnt/[WHATEVER5].mkv failed! [Cannot allocate memory]

[2022/08/07 22:15:36] scanner.c:521: warn: Unsuccessful getting details for /tmp/mnt/[WHATEVER5].mkv

After the last of these error messages, the minidlna process hangs (it is visible in the “ps -wT” output, but it does not answer any queries, like the status webpage)

It is a reproducible problem, it always stops at the same files. However, I cannot tell you how to reproduce the error on any filesets, sorry.

On the other hand, if I install the minidlna package from opkg, copy the config file (“cp /etc/minidlna.conf /opt/etc/minidlna.conf”) and switch to the opkg’s binary (starting minidlna from script) it works without problems. No “[Cannot allocate memory]” messages, no problems. All WHATEVER files are processed seamlessly.

The two binaries are obviously different, and I have not done any debugging what the root of the problem could be.

If you need more info, please tell me.

Comments (8)

  1. pedro repo owner

    Samba now uses FreshTomato Samba Server and minidlna: FreshTomato DLNA Server as a friendly name (and they are hardcoded).

    router_name is now only used as described ie. in syslog.

    Crashes are caused by ffmpeg not minidlna - I checked also older versions of minidlna and the memory problem is also there.

    Remember: I upgraded ffmpeg from 0.6.7 (Sep 23, 2013) to 0.7.17 (Mar 12, 2015) and as you can check for yourself (http://bin.entware.net/armv7sf-k2.6/Packages.html), entware uses 5.1.2 from Sep 24, 2022!

    That probably is the problem specially on newer movie files, because (I think) something is changed now in headers of these files and old ffmpeg can’t handle this, causing cannot-allocate-memory error.

    I have noticed new parameter in Media Server section called “Auto scan media (10 minutes interval)” which is enabled by default. It wasn’t there before and also nothing is mentioned in corresponding WiKi page either. Please explain what it does.

    It was always enabled (hard coded), the only change is that you can now disable it (and I think this option is self-explanatory - if not, see minidlna config file example) .

    4). Minidlna log. I am a bit confused about it. In ticket #243 you specifically mentioned that:

    “minidlna is not able to log to syslog only to its own logfile - there was a patch that made it possible but it was abandoned during the upgrade done by @shibby”

    but in the Changelog for FT 2023.1 there is a note about it:

    • minidlna: use syslog instead of a log file; added as a patch

    Yes, because I ported syslog patch to the latest version of minidlna.

  2. pedro repo owner

    Unfortunately, this issue caused by ffmpeg is still there (despite updating it, but it's still too old to handle new movies/headers). There is no chance to compile newer version of ffmpeg, because of too old toolchain/kernel. BUT if there is a possibility to write a patch for ffmpeg to fix this bug (and if at all possible) I am open to someone posting a PR.

  3. Log in to comment