From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109111: Simple free memory accounting feature.
Date: Tue, 17 Jul 2012 05:45:19 -0400 [thread overview]
Message-ID: <jwv394qafyh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <E1Sr227-00014W-5o@vcs.savannah.gnu.org> (Dmitry Antipov's message of "Tue, 17 Jul 2012 09:01:33 +0400")
> -static EMACS_INT total_free_floats, total_floats;
> +static EMACS_INT total_free_floats, total_floats, total_free_vector_bytes;
Adding total_free_vector_bytes is a good change.
Similarly providing access to malloc's internal data is good, thanks.
> +DEFUN ("memory-free", Fmemory_free, Smemory_free, 0, 0, 0,
> + doc: /* Return a list of two counters that measure how much free memory
> +is hold by the Emacs process. Both counters are in KBytes. First
> +counter shows how much memory holds in a free lists maintained by
> +the Emacs itself. Second counter shows how much free memory is in
> +the heap (freed by Emacs but not released back to the operating
> +system). If the second counter is zero, heap statistics is not
> +available. Since both counters are updated after each garbage
> +collection, use (progn (garbage-collect) (memory-free)) to get
> +accurate numbers. */)
There are two problems, here:
- if the data is unavailable, better return nil than 0.
- we now have 2 ways to get the data, neither of which gives it all:
garbage-collect returns details data but misses the new vector-bytes
and bytes-free, whereas memory-free includes those 2 but only provides
the combined value.
The first problem is obviously a detail, but the second problem needs to
be fixed. The way I see it, it should be fixed by improving
garbage-collect's return value. The only problem with that is backward
compatibility, but AFAIK there are only 2 users of that data:
memory-usage and chart.el, which we can both fix easily.
I suggest we make garbage-collect return its data in a new format
that is more self-descriptive, like an alist where each entry takes the
form (CATEGORY SIZE USED FREE), where CATEGORY would be a symbol (like
`cons') and SIZE is the size of each element in bytes.
Stefan
next parent reply other threads:[~2012-07-17 9:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1Sr227-00014W-5o@vcs.savannah.gnu.org>
2012-07-17 9:45 ` Stefan Monnier [this message]
2012-07-17 13:40 ` [Emacs-diffs] /srv/bzr/emacs/trunk r109111: Simple free memory accounting feature Dmitry Antipov
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=jwv394qafyh.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=dmantipov@yandex.ru \
--cc=emacs-devel@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).