Reduce watchdogd's memory footprint when running daemonized.

This uses the recently-added jemalloc(3) feature of setting the lg_chunk
tuning option to zero to request that memory be allocated in the smallest
chunks possible.  Without this option, the default is to initally map 8MB,
and then the mlockall() call wires that entire allocation even though the
program only uses a few Kbytes of it at runtime.

PR:		bin/173332
Approved by:	cognet (mentor)
This commit is contained in:
Ian Lepore 2013-01-26 21:29:45 +00:00
parent 922c0acd57
commit e6af9f3a37
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=245949

View File

@ -70,6 +70,14 @@ static int fd = -1;
static int nap = 1;
static char *test_cmd = NULL;
/*
* Ask malloc() to map minimum-sized chunks of virtual address space at a time,
* so that mlockall() won't needlessly wire megabytes of unused memory into the
* process. This must be done using the malloc_conf string so that it gets set
* up before the first allocation, which happens before entry to main().
*/
const char * malloc_conf = "lg_chunk:0";
/*
* Periodically pat the watchdog, preventing it from firing.
*/
@ -188,7 +196,7 @@ watchdog_loop(void)
if (watchdog_onoff(0) == 0) {
end_program = 2;
} else {
warnx("Could not stop the watchdog, not exiting");
warnx("Could not stop the watchdog, not exitting");
end_program = 0;
}
}