From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joakim@verona.se Newsgroups: gmane.emacs.devel Subject: Re: Memory leak due to bidi? Date: Tue, 02 Aug 2011 22:37:38 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1312317480 15515 80.91.229.12 (2 Aug 2011 20:38:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 2 Aug 2011 20:38:00 +0000 (UTC) Cc: Eli Zaretskii , Stefan Monnier , emacs-devel@gnu.org To: Lars Magne Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 02 22:37:54 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QoLir-0007LU-Sq for ged-emacs-devel@m.gmane.org; Tue, 02 Aug 2011 22:37:54 +0200 Original-Received: from localhost ([::1]:43640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoLir-0008K5-G8 for ged-emacs-devel@m.gmane.org; Tue, 02 Aug 2011 16:37:53 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:49243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoLip-0008Jj-4s for emacs-devel@gnu.org; Tue, 02 Aug 2011 16:37:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QoLin-00020X-WA for emacs-devel@gnu.org; Tue, 02 Aug 2011 16:37:51 -0400 Original-Received: from batman.blixtvik.net ([87.96.254.3]:43692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoLih-0001yb-3f; Tue, 02 Aug 2011 16:37:43 -0400 Original-Received: from localhost.localdomain (139-210-96-87.cust.blixtvik.se [87.96.210.139]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by batman.blixtvik.net (Postfix) with ESMTP id EB2B27F949D; Tue, 2 Aug 2011 22:37:38 +0200 (CEST) In-Reply-To: (Lars Magne Ingebrigtsen's message of "Tue, 02 Aug 2011 22:15:53 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 87.96.254.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:142756 Archived-At: Lars Magne Ingebrigtsen writes: > joakim@verona.se writes: > >> memory-usage.el makes it human readable. > > Is that something that could be put into GNU ELPA? > >> I used to have lots of memory issues. At the time I made the following >> notes: >> >> - create a memory meter in the modeline, then it would at least be >> possible to see when memory is consumed, and maybe get a clue. > > That sounds useful. gnu elpa would be a good place: ;;; memory-usage.el --- Analyze the memory usage of Emacs in various ways ;; Copyright (C) 2002, 2004 Free Software Foundation, Inc. ;; Author: Stefan Monnier ;; Keywords: maint ;; minor mods by joakim verona ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; ;;; Code: (defun buffer-size-bytes (b) "Return total number of bytes in the buffer contents." (with-current-buffer b (save-restriction (widen) (- (position-bytes (point-max)) (position-bytes (point-min)))))) (defun buffer-gap-bytes (b) "Return total number of bytes in the buffer gap." (with-current-buffer b (gap-size))) (defun buffer-total-bytes (b) "Return total number of ralloc bytes used by buffer." (with-current-buffer b (save-restriction (widen) (+ (position-bytes (point-max)) (- (position-bytes (point-min))) (gap-size))))) ;;;###autoload (defun memory-usage () "List all buffers and their memory usage." (interactive) (pop-to-buffer (get-buffer-create "*Buffer Details*")) (erase-buffer) (let* ((bufs (buffer-list)) (num (length bufs)) (gc-stats (garbage-collect)) (conses (nth 0 gc-stats)) (symbols (nth 1 gc-stats)) (markers (nth 2 gc-stats)) (strings (nth 3 gc-stats)) (vectors (nth 4 gc-stats)) (floats (nth 5 gc-stats)) (intervals (nth 6 gc-stats)) (lisptotal (+ (* 8 (+ (car conses) (cdr conses))) (* 24 (+ (car symbols) (cdr symbols))) (* 20 (+ (car markers) (cdr markers))) strings vectors (* 12 (+ (car floats) (cdr floats))) (* 28 (+ (car intervals) (cdr intervals))))) (buffertotalbytes (apply #'+ (mapcar #'buffer-total-bytes bufs))) ) (insert (format "Garbage collection stats:\n%s\n\n =>" gc-stats)) (insert (format "\t%d bytes in cons cells\n" (* 8 (+ (car conses) (cdr conses))))) (insert (format "\t%d bytes in symbols\n" (* 24 (+ (car symbols) (cdr symbols))))) (insert (format "\t%d bytes in markers\n" (* 20 (+ (car markers) (cdr markers))))) (insert (format "\t%d bytes of string chars\n" strings)) (insert (format "\t%d bytes of vector slots\n" (* 4 vectors))) (insert (format "\t%d bytes in floats\n" (* 12 (+ (car floats) (cdr floats))))) (insert (format "\t%d bytes in intervals\n" (* 28 (+ (car intervals) (cdr intervals))))) (insert (format "\nTotal bytes in lisp objects (not counting string and vector headers): %d\n\n" lisptotal)) (insert (format "Buffer ralloc memory usage:\n%d buffers\n%d bytes total (%d in gaps)\n" num buffertotalbytes (apply #'+ (mapcar #'buffer-gap-bytes bufs)))) (insert (format "%10s\t%s\t%s\n\n" "Size" "Gap" "Name")) (insert (mapconcat (lambda (b) (format "%10d\t%s\t%s" (buffer-size-bytes b) (buffer-gap-bytes b) (buffer-name b))) (sort bufs (lambda (b1 b2) (> (buffer-size-bytes b1) (buffer-size-bytes b2)))) "\n")) (insert "\n") (insert (format "total:%s" (+ lisptotal buffertotalbytes))) (insert "\n")) (goto-char (point-min))) (provide 'memory-usage) ;; arch-tag: 04e012f0-3c59-4319-8d1a-e86204671ec5 ;;; memory-usage.el ends here -- Joakim Verona