Function: warn-maybe-out-of-memory
warn-maybe-out-of-memory is a byte-compiled function defined in
files.el.gz.
Signature
(warn-maybe-out-of-memory SIZE)
Documentation
Warn if an attempt to open file of SIZE bytes may run out of memory.
Source Code
;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun warn-maybe-out-of-memory (size)
"Warn if an attempt to open file of SIZE bytes may run out of memory."
(when (and (numberp size) (not (zerop size))
(integerp out-of-memory-warning-percentage))
(let* ((default-directory temporary-file-directory)
(meminfo (memory-info)))
(when (consp meminfo)
(let ((total-free-memory (float (+ (nth 1 meminfo) (nth 3 meminfo)))))
(when (> (/ size 1024)
(/ (* total-free-memory out-of-memory-warning-percentage)
100.0))
(warn
"You are trying to open a file whose size (%s)
exceeds the %S%% of currently available free memory (%s).
If that fails, try to open it with `find-file-literally'
\(but note that some characters might be displayed incorrectly)."
(funcall byte-count-to-string-function size)
out-of-memory-warning-percentage
(funcall byte-count-to-string-function
(* total-free-memory 1024)))))))))