1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Added periodic calls to malloc_trim(0) to reduce memory consumption

This commit is contained in:
Klaus Schmidinger 2022-11-28 10:44:01 +01:00
parent abb82a2396
commit 6888ea68b6
3 changed files with 13 additions and 2 deletions

View File

@ -3625,6 +3625,7 @@ Onur Sent
for fixing handling the S2SatelliteDeliverySystemDescriptor for transponders broadcasting
in "backwards compatibility mode" according to ETSI EN 300 468
for pointing out some potentially mistakable code in cSectionHandler::SetStatus()
for adding periodic calls to malloc_trim(0) to reduce memory consumption
Helmut Binder <cco@aon.at>
for improving calculating signal strength and quality

View File

@ -9780,7 +9780,7 @@ Video Disk Recorder Revision History
out by Onur Sentürk).
- Official release.
2022-11-23:
2022-11-28:
- Added UPDATE-2.6.0, which was missing in the official 2.6.0 release.
- Fixed unexpected calls of the '-r' script when a recording is interrupted and
@ -9809,3 +9809,5 @@ Video Disk Recorder Revision History
- Added support for kernel based LIRC driver (thanks to Marko Mäkelä). Use the
command line option '--lirc=/dev/lirc0' to use this. Requires kernel version 5.10
or above.
- Added periodic calls to malloc_trim(0) to reduce memory consumption (thanks to
Onur Sentürk).

10
vdr.c
View File

@ -22,13 +22,14 @@
*
* The project's page is at http://www.tvdr.de
*
* $Id: vdr.c 5.9 2022/11/26 13:37:06 kls Exp $
* $Id: vdr.c 5.10 2022/11/28 10:44:01 kls Exp $
*/
#include <getopt.h>
#include <grp.h>
#include <langinfo.h>
#include <locale.h>
#include <malloc.h>
#include <pwd.h>
#include <signal.h>
#include <stdlib.h>
@ -74,6 +75,7 @@
#define MINCHANNELWAIT 10 // seconds to wait between failed channel switchings
#define ACTIVITYTIMEOUT 60 // seconds before starting housekeeping
#define MEMCLEANUPDELTA 3600 // seconds between memory cleanups
#define SHUTDOWNWAIT 300 // seconds to wait in user prompt before automatic shutdown
#define SHUTDOWNRETRY 360 // seconds before trying again to shut down
#define SHUTDOWNFORCEPROMPT 5 // seconds to wait in user prompt to allow forcing shutdown
@ -1578,6 +1580,12 @@ int main(int argc, char *argv[])
cSchedules::Cleanup();
// Plugins housekeeping:
PluginManager.Housekeeping();
// Memory cleanup:
static time_t LastMemoryCleanup = 0;
if ((Now - LastMemoryCleanup) > MEMCLEANUPDELTA) {
malloc_trim(0);
LastMemoryCleanup = Now;
}
}
}