Check out the new USENIX Web site. next up previous
Next: Dynamic Memory Activity Trace Up: Are Mallocs Free of Previous: Hummingbird's Dynamic Memory Activity


GNU Emacs and Its Dynamic Memory Activity

The second application we studied was GNU Emacs version 20.7. We picked GNU Emacs due to its wide use, and because many people use Emacs for their main working environment, and run a single Emacs session for an extended period of time (many days). GNU Emacs is available from https://www.gnu.org/software/emacs/emacs.html.

We instrumented Emacs to generate a trace of its the dynamic memory activity. We run an Emacs macro that listed the contents of /usr/src/ using the dired directory editing mode, visited all of the *.[ch] files found, and changed the string int to unit32 in all files. Emacs edited those files sequentially (one at a time). The directory /usr/src/ contained the source trees of the following Linux kernels: linux-2.0.34, linux-2.1.131, linux-2.2.10-siginfo, linux-2.2.10-swapmod, linux-2.2.10-up-default, linux-2.2.12, linux-2.2.14, linux-2.2.14-mvia, linux-2.2.14-up, linux-2.2.17, linux-2.4.2, linux-ctl, linux-eager and linux-net. There were 73,212 *.[ch] files with total size 2.7GB. Emacs was executing on a PC running linux-2.2.16-SMP. The dynamic memory activity trace contained about 20 million memory allocations and deallocations.

Figure 4 depicts the distribution of Emacs's object sizes against their frequency. It shows that Emacs allocated almost entirely small objects (less than 2K bytes). There seems to be two classes of objects based on their allocation frequency: objects that are allocated a large number of times (more than 1,000) and objects that are allocated a small number of times (less than 32). There is no clear correlation between the object size and its allocation frequency.

Table 2 shows the most common Emacs object sizes, their relative frequency, and the fraction of the memory allocated to objects of this size. The ``total size allocated'' column is the total amount of memory allocated for objects of this size (or size range) during the entire run. Unlike the Hummingbird object size distribution, Emacs has no single object size which dominates the total storage allocated. Moreover, more than 98% of all Emacs objects were small or equal to 648 bytes, and their size was about 65% of the total bytes allocated.

Figures 5 and  6 depict the average number of bytes and objects allocated during the lifetime of an object, respectively. Figure 6 clearly shows that most objects have a similar lifetime, which ranges from 64 K to 1 M object allocations. It seems that those objects were allocated for each source file that Emacs edited, and then they were deallocated when Emacs moved to the next source file.

Figure 3: Number of objects allocated during the lifetime of a Hummingbird memory object as a function of its size.
\includegraphics{objplot.eps}

Figure 4: Distribution of Emacs's object sizes.
\includegraphics{frequency.emacs.eps}

Figure 5: Memory allocated during the lifetime of an Emacs memory object as a function of its size.
\includegraphics{lifeplot.emacs.eps}

Figure 6: Number of objects allocated during the lifetime of an Emacs memory object as a function of its size.
\includegraphics{objplot.emacs.eps}


Table 2: The distribution of the most frequent object sizes in Emacs. The table is sorted by decreasing frequency. Object sizes were rounded to the next multiple of double word (8 bytes).
object % of total % of total
size objects size
(bytes) allocated allocated
40 51.335 8.902
648 15.625 43.897
104 11.368 5.126
64 6.013 1.668
16 3.926 0.272
8 1.496 0.052
16-32 1.549 0.169
48-56 3.075 0.744
72-96 0.141 0.059
112-640 3.554 3.599
656-23568 1.917 35.520
total 100.000 100.000



next up previous
Next: Dynamic Memory Activity Trace Up: Are Mallocs Free of Previous: Hummingbird's Dynamic Memory Activity