aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-07-17 09:24:57 -0700
committerPaul Eggert2012-07-17 09:24:57 -0700
commit6d02fe5b3bf3376f0ea6ecf7fed184fbe84ef1b5 (patch)
tree29bf5d5b4d112ab1c27c7103f621332c0660cc20 /src
parent88ecaf8fa55e7bd0a76c9ea0bda93dbc063f3036 (diff)
downloademacs-6d02fe5b3bf3376f0ea6ecf7fed184fbe84ef1b5.tar.gz
emacs-6d02fe5b3bf3376f0ea6ecf7fed184fbe84ef1b5.zip
* alloc.c (Fmemory_free): Account for memory-free's own storage.
Round up, not down. Improve doc.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/alloc.c48
2 files changed, 30 insertions, 23 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7487e0723a5..b123c433fa8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12012-07-17 Paul Eggert <eggert@cs.ucla.edu>
2
3 * alloc.c (Fmemory_free): Account for memory-free's own storage.
4 Round up, not down. Improve doc.
5
12012-07-17 Dmitry Antipov <dmantipov@yandex.ru> 62012-07-17 Dmitry Antipov <dmantipov@yandex.ru>
2 7
3 Restore old code in allocate_string_data to avoid Faset breakage. 8 Restore old code in allocate_string_data to avoid Faset breakage.
diff --git a/src/alloc.c b/src/alloc.c
index f8456e3645f..7ab3f7b5e9c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6581,33 +6581,35 @@ We divide the value by 1024 to make sure it fits in a Lisp integer. */)
6581} 6581}
6582 6582
6583DEFUN ("memory-free", Fmemory_free, Smemory_free, 0, 0, 0, 6583DEFUN ("memory-free", Fmemory_free, Smemory_free, 0, 0, 0,
6584 doc: /* Return a list of two counters that measure how much free memory 6584 doc: /* Return a list (E H) of two measures of free memory.
6585is hold by the Emacs process. Both counters are in KBytes. First 6585E counts free lists maintained by Emacs itself. H counts the heap,
6586counter shows how much memory holds in a free lists maintained by 6586freed by Emacs but not released to the operating system; this is zero
6587the Emacs itself. Second counter shows how much free memory is in 6587if heap statistics are not available. Both counters are in units of
6588the heap (freed by Emacs but not released back to the operating 65881024 bytes, rounded up. */)
6589system). If the second counter is zero, heap statistics is not
6590available. */)
6591 (void) 6589 (void)
6592{ 6590{
6593 Lisp_Object data[2]; 6591 /* Make the return value first, so that its storage is accounted for. */
6594 6592 Lisp_Object val = Fmake_list (make_number (2), make_number (0));
6595 data[0] = make_number 6593
6596 (min (MOST_POSITIVE_FIXNUM, 6594 XSETCAR (val,
6597 (total_free_conses * sizeof (struct Lisp_Cons) 6595 (make_number
6598 + total_free_markers * sizeof (union Lisp_Misc) 6596 (min (MOST_POSITIVE_FIXNUM,
6599 + total_free_symbols * sizeof (struct Lisp_Symbol) 6597 ((total_free_conses * sizeof (struct Lisp_Cons)
6600 + total_free_floats * sizeof (struct Lisp_Float) 6598 + total_free_markers * sizeof (union Lisp_Misc)
6601 + total_free_intervals * sizeof (struct interval) 6599 + total_free_symbols * sizeof (struct Lisp_Symbol)
6602 + total_free_strings * sizeof (struct Lisp_String) 6600 + total_free_floats * sizeof (struct Lisp_Float)
6603 + total_free_vector_bytes) / 1024)); 6601 + total_free_intervals * sizeof (struct interval)
6602 + total_free_strings * sizeof (struct Lisp_String)
6603 + total_free_vector_bytes
6604 + 1023)
6605 >> 10)))));
6606
6604#ifdef DOUG_LEA_MALLOC 6607#ifdef DOUG_LEA_MALLOC
6605 data[1] = make_number 6608 XSETCAR (XCDR (val),
6606 (min (MOST_POSITIVE_FIXNUM, mallinfo ().fordblks / 1024)); 6609 make_number (min (MOST_POSITIVE_FIXNUM,
6607#else 6610 (mallinfo ().fordblks + 1023) >> 10)));
6608 data[1] = make_number (0);
6609#endif 6611#endif
6610 return Flist (2, data); 6612 return val;
6611} 6613}
6612 6614
6613DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0, 6615DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0,