]> git.xonotic.org Git - xonotic/gmqcc.git/blob - stat.c
Revert "Smaller memory footprint, 4/8 bytes vs 12/24 for individual token lex_ctx...
[xonotic/gmqcc.git] / stat.c
1 /*
2  * Copyright (C) 2012, 2013
3  *     Dale Weiler
4  *     Wolfgang Bumiller
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy of
7  * this software and associated documentation files (the "Software"), to deal in
8  * the Software without restriction, including without limitation the rights to
9  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10  * of the Software, and to permit persons to whom the Software is furnished to do
11  * so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24
25 #include <string.h>
26 #include <stdlib.h>
27
28 #include "gmqcc.h"
29
30 /*
31  * GMQCC performs tons of allocations, constructions, and crazyness
32  * all around. When trying to optimizes systems, or just get fancy
33  * statistics out of the compiler, it's often printf mess. This file
34  * implements the statistics system of the compiler. I.E the allocator
35  * we use to track allocations, and other systems of interest.
36  */
37 #define ST_SIZE 1024
38
39 typedef struct stat_mem_block_s {
40     const char              *file;
41     size_t                   line;
42     size_t                   size;
43     struct stat_mem_block_s *next;
44     struct stat_mem_block_s *prev;
45 } stat_mem_block_t;
46
47 typedef struct {
48     size_t key;
49     size_t value;
50 } stat_size_entry_t, **stat_size_table_t;
51
52 static uint64_t          stat_mem_allocated         = 0;
53 static uint64_t          stat_mem_deallocated       = 0;
54 static uint64_t          stat_mem_allocated_total   = 0;
55 static uint64_t          stat_mem_deallocated_total = 0;
56 static uint64_t          stat_mem_high              = 0;
57 static uint64_t          stat_mem_peak              = 0;
58 static uint64_t          stat_mem_strdups           = 0;
59 static uint64_t          stat_used_strdups          = 0;
60 static uint64_t          stat_used_vectors          = 0;
61 static uint64_t          stat_used_hashtables       = 0;
62 static uint64_t          stat_type_vectors          = 0;
63 static uint64_t          stat_type_hashtables       = 0;
64 static stat_size_table_t stat_size_vectors          = NULL;
65 static stat_size_table_t stat_size_hashtables       = NULL;
66 static stat_mem_block_t *stat_mem_block_root        = NULL;
67
68 /*
69  * A tiny size_t key-value hashtbale for tracking vector and hashtable
70  * sizes. We can use it for other things too, if we need to. This is
71  * very TIGHT, and efficent in terms of space though.
72  */
73 static stat_size_table_t stat_size_new(void) {
74     return (stat_size_table_t)memset(
75         mem_a(sizeof(stat_size_entry_t*) * ST_SIZE),
76         0, ST_SIZE * sizeof(stat_size_entry_t*)
77     );
78 }
79
80 static void stat_size_del(stat_size_table_t table) {
81     size_t i = 0;
82     for (; i < ST_SIZE; i++) if(table[i]) mem_d(table[i]);
83     mem_d(table);
84 }
85
86 static stat_size_entry_t *stat_size_get(stat_size_table_t table, size_t key) {
87     size_t hash = (key % ST_SIZE);
88     while (table[hash] && table[hash]->key != key)
89         hash = (hash + 1) % ST_SIZE;
90     return table[hash];
91 }
92 static void stat_size_put(stat_size_table_t table, size_t key, size_t value) {
93     size_t hash = (key % ST_SIZE);
94     while (table[hash] && table[hash]->key != key)
95         hash = (hash + 1) % ST_SIZE;
96     table[hash]        = (stat_size_entry_t*)mem_a(sizeof(stat_size_entry_t));
97     table[hash]->key   = key;
98     table[hash]->value = value;
99 }
100
101 /*
102  * A basic header of information wrapper allocator. Simply stores
103  * information as a header, returns the memory + 1 past it, can be
104  * retrieved again with - 1. Where type is stat_mem_block_t*.
105  */
106 void *stat_mem_allocate(size_t size, size_t line, const char *file) {
107     stat_mem_block_t *info = (stat_mem_block_t*)malloc(sizeof(stat_mem_block_t) + size);
108     void             *data = (void*)(info + 1);
109
110     if(!info)
111         return NULL;
112
113     info->line = line;
114     info->size = size;
115     info->file = file;
116     info->prev = NULL;
117     info->next = stat_mem_block_root;
118
119     if (stat_mem_block_root)
120         stat_mem_block_root->prev = info;
121
122     stat_mem_block_root       = info;
123     stat_mem_allocated       += size;
124     stat_mem_high            += size;
125     stat_mem_allocated_total ++;
126
127     if (stat_mem_high > stat_mem_peak)
128         stat_mem_peak = stat_mem_high;
129
130     return data;
131 }
132
133 void stat_mem_deallocate(void *ptr) {
134     stat_mem_block_t *info = NULL;
135
136     if (!ptr)
137         return;
138
139     info = ((stat_mem_block_t*)ptr - 1);
140
141     stat_mem_deallocated       += info->size;
142     stat_mem_high              -= info->size;
143     stat_mem_deallocated_total ++;
144
145     if (info->prev) info->prev->next = info->next;
146     if (info->next) info->next->prev = info->prev;
147
148     /* move ahead */
149     if (info == stat_mem_block_root)
150         stat_mem_block_root = info->next;
151
152     free(info);
153 }
154
155 void *stat_mem_reallocate(void *ptr, size_t size, size_t line, const char *file) {
156     stat_mem_block_t *oldinfo = NULL;
157     stat_mem_block_t *newinfo;
158
159     if (!ptr)
160         return stat_mem_allocate(size, line, file);
161
162     /* stay consistent with glic */
163     if (!size) {
164         stat_mem_deallocate(ptr);
165         return NULL;
166     }
167
168     oldinfo = ((stat_mem_block_t*)ptr - 1);
169     newinfo = ((stat_mem_block_t*)malloc(sizeof(stat_mem_block_t) + size));
170
171     if (!newinfo) {
172         stat_mem_deallocate(ptr);
173         return NULL;
174     }
175
176     memcpy(newinfo+1, oldinfo+1, oldinfo->size);
177
178     if (oldinfo->prev) oldinfo->prev->next = oldinfo->next;
179     if (oldinfo->next) oldinfo->next->prev = oldinfo->prev;
180
181     /* move ahead */
182     if (oldinfo == stat_mem_block_root)
183         stat_mem_block_root = oldinfo->next;
184
185     newinfo->line = line;
186     newinfo->size = size;
187     newinfo->file = file;
188     newinfo->prev = NULL;
189     newinfo->next = stat_mem_block_root;
190
191     if (stat_mem_block_root)
192         stat_mem_block_root->prev = newinfo;
193
194     stat_mem_block_root = newinfo;
195     stat_mem_allocated -= oldinfo->size;
196     stat_mem_high      -= oldinfo->size;
197     stat_mem_allocated += newinfo->size;
198     stat_mem_high      += newinfo->size;
199
200     if (stat_mem_high > stat_mem_peak)
201         stat_mem_peak = stat_mem_high;
202
203     free(oldinfo);
204
205     return newinfo + 1;
206 }
207
208 /*
209  * strdup does it's own malloc, we need to track malloc. We don't want
210  * to overwrite malloc though, infact, we can't really hook it at all
211  * without library specific assumptions. So we re implement strdup.
212  */
213 char *stat_mem_strdup(const char *src, size_t line, const char *file, bool empty) {
214     size_t len = 0;
215     char  *ptr = NULL;
216
217     if (!src)
218         return NULL;
219
220     len = strlen(src);
221     if (((!empty) ? len : true) && (ptr = (char*)stat_mem_allocate(len + 1, line, file))) {
222         memcpy(ptr, src, len);
223         ptr[len] = '\0';
224     }
225
226     stat_used_strdups ++;
227     stat_mem_strdups  += len;
228     return ptr;
229 }
230
231 /*
232  * The reallocate function for resizing vectors.
233  */
234 void _util_vec_grow(void **a, size_t i, size_t s) {
235     vector_t          *d = vec_meta(*a);
236     size_t             m = 0;
237     stat_size_entry_t *e = NULL;
238     void              *p = NULL;
239
240     if (*a) {
241         m = 2 * d->allocated + i;
242         p = mem_r(d, s * m + sizeof(vector_t));
243     } else {
244         m = i + 1;
245         p = mem_a(s * m + sizeof(vector_t));
246         ((vector_t*)p)->used = 0;
247         stat_used_vectors++;
248     }
249
250     if (!stat_size_vectors)
251         stat_size_vectors = stat_size_new();
252
253     if ((e = stat_size_get(stat_size_vectors, s))) {
254         e->value ++;
255     } else {
256         stat_size_put(stat_size_vectors, s, 1); /* start off with 1 */
257         stat_type_vectors++;
258     }
259
260     *a = (vector_t*)p + 1;
261     vec_meta(*a)->allocated = m;
262 }
263
264 /*
265  * Hash table for generic data, based on dynamic memory allocations
266  * all around.  This is the internal interface, please look for
267  * EXPOSED INTERFACE comment below
268  */
269 typedef struct hash_node_t {
270     char               *key;   /* the key for this node in table */
271     void               *value; /* pointer to the data as void*   */
272     struct hash_node_t *next;  /* next node (linked list)        */
273 } hash_node_t;
274
275 /*
276  * This is a patched version of the Murmur2 hashing function to use
277  * a proper pre-mix and post-mix setup. Infact this is Murmur3 for
278  * the most part just reinvented.
279  * 
280  * Murmur 2 contains an inner loop such as:
281  * while (l >= 4) {
282  *      u32 k = *(u32*)d;
283  *      k *= m;
284  *      k ^= k >> r;
285  *      k *= m;
286  * 
287  *      h *= m;
288  *      h ^= k;
289  *      d += 4;
290  *      l -= 4;
291  * }
292  * 
293  * The two u32s that form the key are the same value x (pulled from data)
294  * this premix stage will perform the same results for both values. Unrolled
295  * this produces just:
296  *  x *= m;
297  *  x ^= x >> r;
298  *  x *= m;
299  *
300  *  h *= m;
301  *  h ^= x;
302  *  h *= m;
303  *  h ^= x;
304  * 
305  * This appears to be fine, except what happens when m == 1? well x
306  * cancels out entierly, leaving just:
307  *  x ^= x >> r;
308  *  h ^= x;
309  *  h ^= x;
310  * 
311  * So all keys hash to the same value, but how often does m == 1?
312  * well, it turns out testing x for all possible values yeilds only
313  * 172,013,942 unique results instead of 2^32. So nearly ~4.6 bits
314  * are cancelled out on average!
315  * 
316  * This means we have a 14.5% (rounded) chance of colliding more, which
317  * results in another bucket/chain for the hashtable.
318  *
319  * We fix it buy upgrading the pre and post mix ssystems to align with murmur
320  * hash 3.
321  */
322 #if 1
323 #define GMQCC_ROTL32(X, R) (((X) << (R)) | ((X) >> (32 - (R))))
324 GMQCC_INLINE size_t util_hthash(hash_table_t *ht, const char *key) {
325     const unsigned char *data   = (const unsigned char *)key;
326     const size_t         len    = strlen(key);
327     const size_t         block  = len / 4;
328     const uint32_t       mask1  = 0xCC9E2D51;
329     const uint32_t       mask2  = 0x1B873593;
330     const uint32_t      *blocks = (const uint32_t*)(data + block * 4);
331     const unsigned char *tail   = (const unsigned char *)(data + block * 4);
332
333     size_t   i;
334     uint32_t k;
335     uint32_t h = 0x1EF0 ^ len;
336
337     for (i = -block; i; i++) {
338         k  = blocks[i];
339         k *= mask1;
340         k  = GMQCC_ROTL32(k, 15);
341         k *= mask2;
342         h ^= k;
343         h  = GMQCC_ROTL32(h, 13);
344         h  = h * 5 + 0xE6546B64;
345     }
346
347     k = 0;
348     switch (len & 3) {
349         case 3:
350             k ^= tail[2] << 16;
351         case 2:
352             k ^= tail[1] << 8;
353         case 1:
354             k ^= tail[0];
355             k *= mask1;
356             k  = GMQCC_ROTL32(k, 15);
357             k *= mask2;
358             h ^= k;
359     }
360
361     h ^= len;
362     h ^= h >> 16;
363     h *= 0x85EBCA6B;
364     h ^= h >> 13;
365     h *= 0xC2B2AE35;
366     h ^= h >> 16;
367
368     return (size_t) (h % ht->size);
369 }
370 #undef GMQCC_ROTL32
371 #else
372 /* We keep the old for reference */
373 GMQCC_INLINE size_t util_hthash(hash_table_t *ht, const char *key) {
374     const uint32_t       mix   = 0x5BD1E995;
375     const uint32_t       rot   = 24;
376     size_t               size  = strlen(key);
377     uint32_t             hash  = 0x1EF0 /* LICRC TAB */  ^ size;
378     uint32_t             alias = 0;
379     const unsigned char *data  = (const unsigned char*)key;
380
381     while (size >= 4) {
382         alias  = (data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24));
383         alias *= mix;
384         alias ^= alias >> rot;
385         alias *= mix;
386
387         hash  *= mix;
388         hash  ^= alias;
389
390         data += 4;
391         size -= 4;
392     }
393
394     switch (size) {
395         case 3: hash ^= data[2] << 16;
396         case 2: hash ^= data[1] << 8;
397         case 1: hash ^= data[0];
398                 hash *= mix;
399     }
400
401     hash ^= hash >> 13;
402     hash *= mix;
403     hash ^= hash >> 15;
404
405     return (size_t) (hash % ht->size);
406 }
407 #endif
408
409 static hash_node_t *_util_htnewpair(const char *key, void *value) {
410     hash_node_t *node;
411     if (!(node = (hash_node_t*)mem_a(sizeof(hash_node_t))))
412         return NULL;
413
414     if (!(node->key = util_strdupe(key))) {
415         mem_d(node);
416         return NULL;
417     }
418
419     node->value = value;
420     node->next  = NULL;
421
422     return node;
423 }
424
425 /*
426  * EXPOSED INTERFACE for the hashtable implementation
427  * util_htnew(size)                             -- to make a new hashtable
428  * util_htset(table, key, value, sizeof(value)) -- to set something in the table
429  * util_htget(table, key)                       -- to get something from the table
430  * util_htdel(table)                            -- to delete the table
431  */
432 hash_table_t *util_htnew(size_t size) {
433     hash_table_t      *hashtable = NULL;
434     stat_size_entry_t *find      = NULL;
435
436     if (size < 1)
437         return NULL;
438
439     if (!stat_size_hashtables)
440         stat_size_hashtables = stat_size_new();
441
442     if (!(hashtable = (hash_table_t*)mem_a(sizeof(hash_table_t))))
443         return NULL;
444
445     if (!(hashtable->table = (hash_node_t**)mem_a(sizeof(hash_node_t*) * size))) {
446         mem_d(hashtable);
447         return NULL;
448     }
449
450     if ((find = stat_size_get(stat_size_hashtables, size)))
451         find->value++;
452     else {
453         stat_type_hashtables++;
454         stat_size_put(stat_size_hashtables, size, 1);
455     }
456
457     hashtable->size = size;
458     memset(hashtable->table, 0, sizeof(hash_node_t*) * size);
459
460     stat_used_hashtables++;
461     return hashtable;
462 }
463
464 void util_htseth(hash_table_t *ht, const char *key, size_t bin, void *value) {
465     hash_node_t *newnode = NULL;
466     hash_node_t *next    = NULL;
467     hash_node_t *last    = NULL;
468
469     next = ht->table[bin];
470
471     while (next && next->key && strcmp(key, next->key) > 0)
472         last = next, next = next->next;
473
474     /* already in table, do a replace */
475     if (next && next->key && strcmp(key, next->key) == 0) {
476         next->value = value;
477     } else {
478         /* not found, grow a pair man :P */
479         newnode = _util_htnewpair(key, value);
480         if (next == ht->table[bin]) {
481             newnode->next  = next;
482             ht->table[bin] = newnode;
483         } else if (!next) {
484             last->next = newnode;
485         } else {
486             newnode->next = next;
487             last->next = newnode;
488         }
489     }
490 }
491
492 void util_htset(hash_table_t *ht, const char *key, void *value) {
493     util_htseth(ht, key, util_hthash(ht, key), value);
494 }
495
496 void *util_htgeth(hash_table_t *ht, const char *key, size_t bin) {
497     hash_node_t *pair = ht->table[bin];
498
499     while (pair && pair->key && strcmp(key, pair->key) > 0)
500         pair = pair->next;
501
502     if (!pair || !pair->key || strcmp(key, pair->key) != 0)
503         return NULL;
504
505     return pair->value;
506 }
507
508 void *util_htget(hash_table_t *ht, const char *key) {
509     return util_htgeth(ht, key, util_hthash(ht, key));
510 }
511
512 void *code_util_str_htgeth(hash_table_t *ht, const char *key, size_t bin) {
513     hash_node_t *pair;
514     size_t len, keylen;
515     int cmp;
516
517     keylen = strlen(key);
518
519     pair = ht->table[bin];
520     while (pair && pair->key) {
521         len = strlen(pair->key);
522         if (len < keylen) {
523             pair = pair->next;
524             continue;
525         }
526         if (keylen == len) {
527             cmp = strcmp(key, pair->key);
528             if (cmp == 0)
529                 return pair->value;
530             if (cmp < 0)
531                 return NULL;
532             pair = pair->next;
533             continue;
534         }
535         cmp = strcmp(key, pair->key + len - keylen);
536         if (cmp == 0) {
537             uintptr_t up = (uintptr_t)pair->value;
538             up += len - keylen;
539             return (void*)up;
540         }
541         pair = pair->next;
542     }
543     return NULL;
544 }
545
546 /*
547  * Free all allocated data in a hashtable, this is quite the amount
548  * of work.
549  */
550 void util_htrem(hash_table_t *ht, void (*callback)(void *data)) {
551     size_t i = 0;
552
553     for (; i < ht->size; ++i) {
554         hash_node_t *n = ht->table[i];
555         hash_node_t *p;
556
557         /* free in list */
558         while (n) {
559             if (n->key)
560                 mem_d(n->key);
561             if (callback)
562                 callback(n->value);
563             p = n;
564             n = p->next;
565             mem_d(p);
566         }
567
568     }
569     /* free table */
570     mem_d(ht->table);
571     mem_d(ht);
572 }
573
574 void util_htrmh(hash_table_t *ht, const char *key, size_t bin, void (*cb)(void*)) {
575     hash_node_t **pair = &ht->table[bin];
576     hash_node_t *tmp;
577
578     while (*pair && (*pair)->key && strcmp(key, (*pair)->key) > 0)
579         pair = &(*pair)->next;
580
581     tmp = *pair;
582     if (!tmp || !tmp->key || strcmp(key, tmp->key) != 0)
583         return;
584
585     if (cb)
586         (*cb)(tmp->value);
587
588     *pair = tmp->next;
589     mem_d(tmp->key);
590     mem_d(tmp);
591 }
592
593 void util_htrm(hash_table_t *ht, const char *key, void (*cb)(void*)) {
594     util_htrmh(ht, key, util_hthash(ht, key), cb);
595 }
596
597 void util_htdel(hash_table_t *ht) {
598     util_htrem(ht, NULL);
599 }
600
601 /*
602  * The following functions below implement printing / dumping of statistical
603  * information.
604  */
605 static void stat_dump_mem_contents(stat_mem_block_t *memory, uint16_t cols) {
606     uint32_t i, j;
607     for (i = 0; i < memory->size + ((memory->size % cols) ? (cols - memory->size % cols) : 0); i++) {
608         if (i % cols == 0)    con_out(" 0x%06X: ", i);
609         if (i < memory->size) con_out("%02X " , 0xFF & ((unsigned char*)(memory + 1))[i]);
610         else                  con_out(" ");
611
612         if ((uint16_t)(i % cols) == (cols - 1)) {
613             for (j = i - (cols - 1); j <= i; j++) {
614                 con_out("%c",
615                     (j >= memory->size)
616                         ? ' '
617                         : (util_isprint(((unsigned char*)(memory + 1))[j]))
618                             ? 0xFF & ((unsigned char*)(memory + 1)) [j]
619                             : '.'
620                 );
621             }
622             con_out("\n");
623         }
624     }
625 }
626
627 static void stat_dump_mem_leaks(void) {
628     stat_mem_block_t *info;
629     for (info = stat_mem_block_root; info; info = info->next) {
630         con_out("lost: %u (bytes) at %s:%u\n",
631             info->size,
632             info->file,
633             info->line
634         );
635
636         stat_dump_mem_contents(info, OPTS_OPTION_U16(OPTION_MEMDUMPCOLS));
637     }
638 }
639
640 static void stat_dump_mem_info(void) {
641     con_out("Memory Information:\n\
642     Total allocations:   %llu\n\
643     Total deallocations: %llu\n\
644     Total allocated:     %f (MB)\n\
645     Total deallocated:   %f (MB)\n\
646     Total peak memory:   %f (MB)\n\
647     Total leaked memory: %f (MB) in %llu allocations\n",
648         stat_mem_allocated_total,
649         stat_mem_deallocated_total,
650         (float)(stat_mem_allocated)                        / 1048576.0f,
651         (float)(stat_mem_deallocated)                      / 1048576.0f,
652         (float)(stat_mem_peak)                             / 1048576.0f,
653         (float)(stat_mem_allocated - stat_mem_deallocated) / 1048576.0f,
654         stat_mem_allocated_total - stat_mem_deallocated_total
655     );
656 }
657
658 static void stat_dump_stats_table(stat_size_table_t table, const char *string, uint64_t *size) {
659     size_t i,j;
660
661     if (!table)
662         return;
663
664     for (i = 0, j = 1; i < ST_SIZE; i++) {
665         stat_size_entry_t *entry;
666
667         if (!(entry = table[i]))
668             continue;
669
670         con_out(string, (unsigned)j, (unsigned)entry->key, (unsigned)entry->value);
671         j++;
672
673         if (size)
674             *size += entry->key * entry->value;
675     }
676 }
677
678 void stat_info() {
679     if (OPTS_OPTION_BOOL(OPTION_MEMCHK) ||
680         OPTS_OPTION_BOOL(OPTION_STATISTICS)) {
681         uint64_t mem = 0;
682
683         con_out("Memory Statistics:\n\
684     Total vectors allocated:       %llu\n\
685     Total string duplicates:       %llu\n\
686     Total string duplicate memory: %f (MB)\n\
687     Total hashtables allocated:    %llu\n\
688     Total unique vector sizes:     %llu\n",
689             stat_used_vectors,
690             stat_used_strdups,
691             (float)(stat_mem_strdups) / 1048576.0f,
692             stat_used_hashtables,
693             stat_type_vectors
694         );
695
696         stat_dump_stats_table (
697             stat_size_vectors,
698             "        %2u| # of %5u byte vectors: %u\n",
699             &mem
700         );
701
702         con_out (
703             "    Total unique hashtable sizes: %llu\n",
704             stat_type_hashtables
705         );
706
707         stat_dump_stats_table (
708             stat_size_hashtables,
709             "        %2u| # of %5u element hashtables: %u\n",
710             NULL
711         );
712
713         con_out (
714             "    Total vector memory:          %f (MB)\n\n",
715             (float)(mem) / 1048576.0f
716         );
717     }
718
719     if (stat_size_vectors)
720         stat_size_del(stat_size_vectors);
721     if (stat_size_hashtables)
722         stat_size_del(stat_size_hashtables);
723
724     if (OPTS_OPTION_BOOL(OPTION_DEBUG) ||
725         OPTS_OPTION_BOOL(OPTION_MEMCHK))
726         stat_dump_mem_info();
727
728     if (OPTS_OPTION_BOOL(OPTION_DEBUG))
729         stat_dump_mem_leaks();
730 }
731 #undef ST_SIZE