unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Sergey Vinokurov <serg.foo@gmail.com>
To: 53310@debbugs.gnu.org
Subject: bug#53310: [PATCH] cannot use memory-report-object-size in pristine session
Date: Sun, 16 Jan 2022 23:48:06 +0000	[thread overview]
Message-ID: <1e784385-d105-0ae2-fd9e-c626eb3d68ac@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1441 bytes --]


When I try to to use memory-report-object-size I get following error on 
Emacs 28.0 pretest:


$ emacs --batch -Q --eval "(progn (require 'memory-report) (message 
\"%s\" (memory-report-object-size '(a b \"cd\"))))"
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
   #f(compiled-function (counted value) #<bytecode 
-0x1a1202ad2c7fe610>)(#<hash-table eq 1/19 0x157c06d25887> (a b "cd"))
   apply(#f(compiled-function (counted value) #<bytecode 
-0x1a1202ad2c7fe610>) #<hash-table eq 1/19 0x157c06d25887> (a b "cd") nil)
   memory-report--object-size-1(#<hash-table eq 1/19 0x157c06d25887> (a 
b "cd"))
   memory-report--object-size(#<hash-table eq 1/19 0x157c06d25887> (a b 
"cd"))
   memory-report-object-size((a b "cd"))
   (message "%s" (memory-report-object-size '(a b "cd")))
   (progn (require 'memory-report) (message "%s" 
(memory-report-object-size '(a b "cd"))))
   command-line-1(("--eval" "(progn (require 'memory-report) (message 
\"%s\" (mem..."))
   command-line()
   normal-top-level()


While this command line does work:


$ emacs --batch -Q --eval "(progn (require 'memory-report) 
(memory-report--garbage-collect) (message \"%s\" 
(memory-report-object-size '(a b \"cd\"))))"
82


Not sure whether I'm using memory-report-object-size as intended but its 
initialization is definitely not doing anything since 
memory-report--type-size is initialized to a hash table in the same module.

Sergey

[-- Attachment #2: 0001-Fix-memory-report-object-size-to-initialize-memory-r.patch --]
[-- Type: text/x-patch, Size: 986 bytes --]

From feac83270d642e0652487cbea802ce527bdbe7e4 Mon Sep 17 00:00:00 2001
From: Sergey Vinokurov <serg.foo@gmail.com>
Date: Sun, 16 Jan 2022 23:40:39 +0000
Subject: [PATCH] Fix memory-report-object-size to initialize
 memory-report--type-size

    * lisp/emacs-lisp/memory-report.el (memory-report-object-size):
      Fix initialization of memory-report--type-size.
---
 lisp/emacs-lisp/memory-report.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/memory-report.el b/lisp/emacs-lisp/memory-report.el
index eae0e36234..52db0af7fc 100644
--- a/lisp/emacs-lisp/memory-report.el
+++ b/lisp/emacs-lisp/memory-report.el
@@ -75,7 +75,7 @@ memory-report
 
 (defun memory-report-object-size (object)
   "Return the size of OBJECT in bytes."
-  (unless memory-report--type-size
+  (when (= 0 (hash-table-count memory-report--type-size))
     (memory-report--garbage-collect))
   (memory-report--object-size (make-hash-table :test #'eq) object))
 
-- 
2.34.1


             reply	other threads:[~2022-01-16 23:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-16 23:48 Sergey Vinokurov [this message]
2022-01-21 11:42 ` bug#53310: [PATCH] cannot use memory-report-object-size in pristine session Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1e784385-d105-0ae2-fd9e-c626eb3d68ac@gmail.com \
    --to=serg.foo@gmail.com \
    --cc=53310@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).