aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-07-20 18:07:28 +0400
committerDmitry Antipov2012-07-20 18:07:28 +0400
commitf8643a6b9e35af22b69a84f83df5d9410de82f16 (patch)
tree922310c5216f43845258318070a72c2f616c063c /src/alloc.c
parentdac616ff9f51b77e399a06863a79446958c4f840 (diff)
downloademacs-f8643a6b9e35af22b69a84f83df5d9410de82f16.tar.gz
emacs-f8643a6b9e35af22b69a84f83df5d9410de82f16.zip
Extend the value returned by Fgarbage_collect with heap statistics.
* alloc.c (Qheap): New symbol. (syms_of_alloc): DEFSYM it. (Fgarbage_collect): If DOUG_LEA_MALLOC, add mallinfo data. (Fmemory_free): Remove. (syms_of_alloc): Don't defsubr it. * buffer.c (Fcompact_buffer): Remove. (syms_of_buffer): Don't defsubr it.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/src/alloc.c b/src/alloc.c
index e7d67e95dbe..05e676836c5 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -258,7 +258,7 @@ static char *stack_copy;
258static ptrdiff_t stack_copy_size; 258static ptrdiff_t stack_copy_size;
259#endif 259#endif
260 260
261static Lisp_Object Qstring_bytes, Qvector_slots; 261static Lisp_Object Qstring_bytes, Qvector_slots, Qheap;
262static Lisp_Object Qgc_cons_threshold; 262static Lisp_Object Qgc_cons_threshold;
263Lisp_Object Qchar_table_extra_slots; 263Lisp_Object Qchar_table_extra_slots;
264 264
@@ -5396,7 +5396,7 @@ See Info node `(elisp)Garbage Collection'. */)
5396 char stack_top_variable; 5396 char stack_top_variable;
5397 ptrdiff_t i; 5397 ptrdiff_t i;
5398 int message_p; 5398 int message_p;
5399 Lisp_Object total[10]; 5399 Lisp_Object total[11];
5400 ptrdiff_t count = SPECPDL_INDEX (); 5400 ptrdiff_t count = SPECPDL_INDEX ();
5401 EMACS_TIME t1; 5401 EMACS_TIME t1;
5402 5402
@@ -5655,6 +5655,15 @@ See Info node `(elisp)Garbage Collection'. */)
5655 total[9] = list3 (Qbuffer, make_number (sizeof (struct buffer)), 5655 total[9] = list3 (Qbuffer, make_number (sizeof (struct buffer)),
5656 bounded_number (total_buffers)); 5656 bounded_number (total_buffers));
5657 5657
5658 total[10] = list4 (Qheap, make_number (1024),
5659#ifdef DOUG_LEA_MALLOC
5660 bounded_number ((mallinfo ().uordblks + 1023) >> 10),
5661 bounded_number ((mallinfo ().fordblks + 1023) >> 10)
5662#else
5663 Qnil, Qnil
5664#endif
5665 );
5666
5658#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 5667#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
5659 { 5668 {
5660 /* Compute average percentage of zombies. */ 5669 /* Compute average percentage of zombies. */
@@ -6602,33 +6611,6 @@ We divide the value by 1024 to make sure it fits in a Lisp integer. */)
6602 return end; 6611 return end;
6603} 6612}
6604 6613
6605DEFUN ("memory-free", Fmemory_free, Smemory_free, 0, 0, 0,
6606 doc: /* Return a list (E H) of two measures of free memory.
6607E counts free lists maintained by Emacs itself. H counts the heap,
6608freed by Emacs but not released to the operating system; this is zero
6609if heap statistics are not available. Both counters are in units of
66101024 bytes, rounded up. */)
6611 (void)
6612{
6613 /* Make the return value first, so that its storage is accounted for. */
6614 Lisp_Object val = Fmake_list (make_number (2), make_number (0));
6615
6616 XSETCAR (val,
6617 bounded_number
6618 ((total_free_conses * sizeof (struct Lisp_Cons)
6619 + total_free_markers * sizeof (union Lisp_Misc)
6620 + total_free_symbols * sizeof (struct Lisp_Symbol)
6621 + total_free_floats * sizeof (struct Lisp_Float)
6622 + total_free_intervals * sizeof (struct interval)
6623 + total_free_strings * sizeof (struct Lisp_String)
6624 + total_free_vector_slots * word_size
6625 + 1023) >> 10));
6626#ifdef DOUG_LEA_MALLOC
6627 XSETCAR (XCDR (val), bounded_number ((mallinfo ().fordblks + 1023) >> 10));
6628#endif
6629 return val;
6630}
6631
6632DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0, 6614DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0,
6633 doc: /* Return a list of counters that measure how much consing there has been. 6615 doc: /* Return a list of counters that measure how much consing there has been.
6634Each of these counters increments for a certain kind of object. 6616Each of these counters increments for a certain kind of object.
@@ -6845,6 +6827,7 @@ do hash-consing of the objects allocated to pure space. */);
6845 6827
6846 DEFSYM (Qstring_bytes, "string-bytes"); 6828 DEFSYM (Qstring_bytes, "string-bytes");
6847 DEFSYM (Qvector_slots, "vector-slots"); 6829 DEFSYM (Qvector_slots, "vector-slots");
6830 DEFSYM (Qheap, "heap");
6848 6831
6849 DEFSYM (Qgc_cons_threshold, "gc-cons-threshold"); 6832 DEFSYM (Qgc_cons_threshold, "gc-cons-threshold");
6850 DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots"); 6833 DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots");
@@ -6868,7 +6851,6 @@ The time is in seconds as a floating point value. */);
6868 defsubr (&Spurecopy); 6851 defsubr (&Spurecopy);
6869 defsubr (&Sgarbage_collect); 6852 defsubr (&Sgarbage_collect);
6870 defsubr (&Smemory_limit); 6853 defsubr (&Smemory_limit);
6871 defsubr (&Smemory_free);
6872 defsubr (&Smemory_use_counts); 6854 defsubr (&Smemory_use_counts);
6873 6855
6874#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 6856#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES