如果 (memory-limit)
算出的是字节数除以 1024, 那就是实际占用的两倍大小.
楼主用的是 Windows.
不存在「自己估计内存占用」,也没有「和实际值相差很大」,是你把不同的项目放在一起比较。
(symbol-function 'memory-limit)
;; =>
;; (defun memory-limit ()
;; "Return an estimate of Emacs virtual memory usage, divided by 1024."
;; (or (cdr (assq 'vsize (process-attributes (emacs-pid)))) 0))
(memory-limit)
;; => 6835232
;; ^^^^^^^
(shell-command-to-string "ps aux | egrep 'Emacs.app|VSZ'")
;; =>
;; PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
;; 9054 4.3 2.3 6835516 240544 ?? S Tue01PM 72:12.56 /Applications/Emacs.app/Contents/MacOS/Emacs
;; ^^^^^^^
嗯, 我后来查看了 memory-limit
的具体定义, 找了篇文章. 看二楼.