The first thing I always do on output of
M-x show-memory-usage
is to sort each section numerically by the last (total usage) column.
This got tiring, hence I created this somewhat ugly patch.
I am editing the output after the fact since the current design prints
each object in the order returned by memfun.
I'll wait for approval or supersession of this patch by Ben before I
commit.
Best regards,
Adrian
xemacs-21.5-clean ChangeLog patch:
Diff command: cvs -q diff -U 0
Files affected: lisp/ChangeLog
Index: lisp/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/ChangeLog,v
retrieving revision 1.646
diff -u -U0 -r1.646 ChangeLog
--- lisp/ChangeLog 23 Feb 2005 22:25:15 -0000 1.646
+++ lisp/ChangeLog 25 Feb 2005 00:10:59 -0000
@@ -0,0 +1,5 @@
+2005-02-25 Adrian Aichner <adrian(a)xemacs.org>
+
+ * diagnose.el: Fix typo.
+ * diagnose.el (show-memory-usage): Sort sections by total usage.
+
xemacs-21.5-clean source patch:
Diff command: cvs -f -z3 -q diff -u -w -N
Files affected: lisp/diagnose.el
Index: lisp/diagnose.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/diagnose.el,v
retrieving revision 1.1
diff -u -w -r1.1 diagnose.el
--- lisp/diagnose.el 20 Mar 2002 10:20:50 -0000 1.1
+++ lisp/diagnose.el 25 Feb 2005 00:08:42 -0000
@@ -1,4 +1,4 @@
-;;; debug.el --- routines for debugging problems in XEmacs
+;;; diagnose.el --- routines for debugging problems in XEmacs
;; Copyright (C) 2002 Ben Wing.
@@ -62,7 +62,7 @@
(incf linelen fieldlen)
(format "%%%ds" fieldlen)))
types "")
- (progn (incf linelen 8) "%8s\n")))
+ (progn (incf linelen 9) "%9s\n")))
(princ "\n")
(princ (apply 'format fmt objtypename
(append types (list 'total))))
@@ -85,24 +85,56 @@
(list totaltotal))))
totaltotal)))
- (let ((grandtotal 0))
- (with-output-to-temp-buffer "*memory usage*"
+ (let ((grandtotal 0)
+ (buffer "*memory usage*")
+ begin)
+ (with-output-to-temp-buffer buffer
+ (save-excursion
+ (set-buffer buffer)
(when-fboundp 'charset-list
+ (setq begin (point))
(incf grandtotal
(show-foo-stats 'charset (charset-list)
#'charset-memory-usage))
+ (sort-numeric-fields -1
+ (save-excursion
+ (goto-char begin)
+ (forward-line 2)
+ (point))
+ (save-excursion
+ (forward-line -2)
+ (point)))
(princ "\n"))
+ (setq begin (point))
(incf grandtotal
(show-foo-stats 'buffer (buffer-list) #'buffer-memory-usage))
+ (sort-numeric-fields -1
+ (save-excursion
+ (goto-char begin)
+ (forward-line 3)
+ (point))
+ (save-excursion
+ (forward-line -2)
+ (point)))
(princ "\n")
+ (setq begin (point))
(incf grandtotal
(show-foo-stats 'window (mapcan #'(lambda (fr)
(window-list fr t))
(frame-list))
#'window-memory-usage))
+ (sort-numeric-fields -1
+ (save-excursion
+ (goto-char begin)
+ (forward-line 3)
+ (point))
+ (save-excursion
+ (forward-line -2)
+ (point)))
(princ "\n")
(let ((total 0)
(fmt "%-30s%10s\n"))
+ (setq begin (point))
(princ (format fmt "object" "storage"))
(princ (make-string 40 ?-))
(princ "\n")
@@ -120,6 +152,14 @@
(princ "\n")
(princ (format fmt "total" total))
(incf grandtotal total))
+ (sort-numeric-fields -1
+ (save-excursion
+ (goto-char begin)
+ (forward-line 2)
+ (point))
+ (save-excursion
+ (forward-line -2)
+ (point)))
- (princ (format "\n\ngrand total: %s\n" grandtotal))
+ (princ (format "\n\ngrand total: %s\n" grandtotal)))
grandtotal))))
--
Adrian Aichner
mailto:adrian@xemacs.org
http://www.xemacs.org/