emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109111: Simple free memory accou


From: Stefan Monnier
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109111: Simple free memory accounting feature.
Date: Tue, 17 Jul 2012 05:45:19 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

> -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]