diff options
Diffstat (limited to 'lisp/emacs-lisp/memory-report.el')
-rw-r--r-- | lisp/emacs-lisp/memory-report.el | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/memory-report.el b/lisp/emacs-lisp/memory-report.el index 3d6ca957e63..aee2a0079ca 100644 --- a/lisp/emacs-lisp/memory-report.el +++ b/lisp/emacs-lisp/memory-report.el @@ -44,6 +44,8 @@ by counted more than once." (pop-to-buffer "*Memory Report*") (special-mode) (button-mode 1) + (setq-local revert-buffer-function (lambda (_ignore-auto _noconfirm) + (memory-report))) (setq truncate-lines t) (message "Gathering data...") (let ((reports (append (memory-report--garbage-collect) @@ -182,7 +184,7 @@ by counted more than once." (cl-defmethod memory-report--object-size-1 (_ (value symbol)) ;; Don't count global symbols -- makes sizes of lists of symbols too - ;; heavey. + ;; heavy. (if (intern-soft value obarray) 0 (memory-report--size 'symbol))) @@ -214,22 +216,21 @@ by counted more than once." (setf (gethash value counted) t) (when (car value) (cl-incf total (memory-report--object-size counted (car value)))) - (if (cdr value) - (if (consp (cdr value)) - (if (gethash (cdr value) counted) - (setq value nil) - (setq value (cdr value))) - (cl-incf total (memory-report--object-size counted (cdr value))) - (setq value nil)) - (setq value nil))) + (let ((next (cdr value))) + (setq value (when next + (if (consp next) + (unless (gethash next counted) + (cdr value)) + (cl-incf total (memory-report--object-size + counted next)) + nil))))) total)) (cl-defmethod memory-report--object-size-1 (counted (value vector)) (let ((total (+ (memory-report--size 'vector) (* (memory-report--size 'object) (length value))))) (cl-loop for elem across value - do (setf (gethash elem counted) t) - (cl-incf total (memory-report--object-size counted elem))) + do (cl-incf total (memory-report--object-size counted elem))) total)) (cl-defmethod memory-report--object-size-1 (counted (value hash-table)) @@ -237,8 +238,6 @@ by counted more than once." (* (memory-report--size 'object) (hash-table-size value))))) (maphash (lambda (key elem) - (setf (gethash key counted) t) - (setf (gethash elem counted) t) (cl-incf total (memory-report--object-size counted key)) (cl-incf total (memory-report--object-size counted elem))) value) @@ -295,7 +294,7 @@ by counted more than once." (- (position-bytes (point-min))) (gap-size))) (seq-reduce #'+ (mapcar (lambda (elem) - (if (cdr elem) + (if (and (consp elem) (cdr elem)) (memory-report--object-size (make-hash-table :test #'eq) (cdr elem)) |