}
}
+ if (max_cache_size == 0) {
+ cfg_obj_log(obj, ISC_LOG_WARNING,
+ "'max-cache-size' can't be zero or unlimited; "
+ "falling back to default");
+ max_cache_size = SIZE_AS_PERCENT;
+ max_cache_size_percent = 90;
+ }
+
if (max_cache_size == SIZE_AS_PERCENT) {
uint64_t totalphys = isc_meminfo_totalphys();
- max_cache_size =
- (size_t)(totalphys * max_cache_size_percent / 100);
if (totalphys == 0) {
- cfg_obj_log(obj, ISC_LOG_WARNING,
+ cfg_obj_log(obj, ISC_LOG_ERROR,
"Unable to determine amount of physical "
- "memory, setting 'max-cache-size' to "
- "unlimited");
+ "memory, setting 'max-cache-size' to the "
+ "minimum value");
+ max_cache_size = 1;
} else {
+ max_cache_size = (size_t)(totalphys *
+ max_cache_size_percent / 100);
+
cfg_obj_log(obj, ISC_LOG_INFO,
"'max-cache-size %d%%' "
"- setting to %" PRIu64 "MB "
- 2 MB for views with :any:`recursion` set to ``no``.
Any positive value smaller than 2 MB is ignored and reset to 2 MB.
- The keyword ``unlimited``, or the value ``0``, places no limit on the
- cache size; records are then purged from the cache only when they
- expire (according to their TTLs).
+
+ .. warning::
+
+ Previously, the keyword ``unlimited``, or the value ``0``, placed
+ no limit on the cache size; this is no longer permitted as
+ TTL-based cleaning has been removed from :iscman:`named`.
.. note::
.. note::
:any:`max-cache-size` does not work reliably for a maximum
- amount of memory of 100 MB or lower.
+ amount of memory of 256 MB or lower.
Upon startup and reconfiguration, caches with a limited size
preallocate a small amount of memory (less than 1% of
internal cache structures.
On systems where detection of the amount of physical memory is not
- supported, percentage-based values fall back to ``unlimited``. Note
- that the amount of physical memory available is only detected on
- startup, so :iscman:`named` does not adjust the cache size limits if the
- amount of physical memory is changed at runtime.
+ supported, the :iscman:`named` will fail to start.
+
+ .. note::
+
+ The amount of physical memory available is only detected on startup, so
+ :iscman:`named` does not adjust the cache size limits if the amount of
+ physical memory is changed at runtime.
On Linux, the system administrator can use `cgroup`_ (Control Group)
mechanism to limit the amount of available memory to the process. This limit
updatewater(dns_cache_t *cache) {
size_t hi = cache->size - (cache->size >> 3); /* ~ 7/8ths. */
size_t lo = cache->size - (cache->size >> 2); /* ~ 3/4ths. */
- if (cache->size == 0U || hi == 0U || lo == 0U) {
- isc_mem_clearwater(cache->tmctx);
- } else {
- isc_mem_setwater(cache->tmctx, hi, lo);
- }
+ isc_mem_setwater(cache->tmctx, hi, lo);
}
void
* Impose a minimum cache size; pathological things happen if there
* is too little room.
*/
- if (size != 0U && size < DNS_CACHE_MINSIZE) {
+ if (size < DNS_CACHE_MINSIZE) {
size = DNS_CACHE_MINSIZE;
}
void
dns_cache_setcachesize(dns_cache_t *cache, size_t size);
/*%<
- * Set the maximum cache size. 0 means unlimited.
+ * Set the maximum cache size.
*/
size_t