Function: garbage-collect-heapsize
garbage-collect-heapsize is a function defined in alloc.c.
Signature
(garbage-collect-heapsize)
Documentation
Return a list with info on amount of space in use.
This info may not be fully up to date unless it is called right after
a full garbage collection cycle.
Each entry has the form (NAME SIZE USED FREE), where:
- NAME is a symbol describing the kind of objects this entry represents,
- SIZE is the number of bytes used by each one,
- USED is the number of those objects that were found live in the heap,
- FREE is the number of those objects that are not live but that Emacs
keeps around for future allocations (maybe because it does not know how
to return them to the OS).
Probably introduced at or before Emacs version 31.1.
Source Code
// Defined in /usr/src/emacs/src/alloc.c
{
struct gcstat gcst = gcstat;
/* FIXME: Maybe we could/should add a field countaing the approximate
amount of memory allocated since the last GC, such as
'gc_threshold - consing_until_gc'. */
Lisp_Object total[] = {
list4 (Qconses, make_fixnum (sizeof (struct Lisp_Cons)),
make_int (gcst.total_conses),
make_int (gcst.total_free_conses)),
list4 (Qsymbols, make_fixnum (sizeof (struct Lisp_Symbol)),
make_int (gcst.total_symbols),
make_int (gcst.total_free_symbols)),
list4 (Qstrings, make_fixnum (sizeof (struct Lisp_String)),
make_int (gcst.total_strings),
make_int (gcst.total_free_strings)),
list3 (Qstring_bytes, make_fixnum (1),
make_int (gcst.total_string_bytes)),
list3 (Qvectors,
make_fixnum (header_size + sizeof (Lisp_Object)),
make_int (gcst.total_vectors)),
list4 (Qvector_slots, make_fixnum (word_size),
make_int (gcst.total_vector_slots),
make_int (gcst.total_free_vector_slots)),
list4 (Qfloats, make_fixnum (sizeof (struct Lisp_Float)),
make_int (gcst.total_floats),
make_int (gcst.total_free_floats)),
list4 (Qintervals, make_fixnum (sizeof (struct interval)),
make_int (gcst.total_intervals),
make_int (gcst.total_free_intervals)),
list3 (Qbuffers, make_fixnum (sizeof (struct buffer)),
make_int (gcst.total_buffers)),
#ifdef DOUG_LEA_MALLOC
list4 (Qheap, make_fixnum (1024),
make_int ((mallinfo ().uordblks + 1023) >> 10),
make_int ((mallinfo ().fordblks + 1023) >> 10)),
#endif
};
return CALLMANY (Flist, total);
}