2 * Copyright (C) 2013 Free Software Foundation, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 # include "gnashconfig.h"
27 #ifdef USE_STATS_MEMORY
29 /* Borrowed from malloc.h, as this is Linux specific. This has been
30 * added to jemalloc so the existing memory profiling in Gnash will
31 * continue to work. Most of these fields aren't used by the Gnash
32 * memory profiling, but we leave them here for a semblance of
33 * portability. The only fields Gnash uses are arena, uordblks. and
37 int arena
; /* non-mmapped space allocated from system */
38 int ordblks
; /* number of free chunks UNUSED */
39 int smblks
; /* number of fastbin blocks UNUSED */
40 int hblks
; /* number of mmapped regions UNUSED */
41 int hblkhd
; /* space in mmapped regions UNUSED */
42 int usmblks
; /* maximum total allocated space UNUSED */
43 int fsmblks
; /* space available in freed fastbin blocks UNUSED */
44 int uordblks
; /* total allocated space */
45 int fordblks
; /* total free space */
46 int keepcost
; /* top-most, releasable space UNUSED */
49 struct mallinfo
mallinfo (void);
54 struct mallinfo mi
= {0,};
56 size_t len
= sizeof(mi
.arena
);
57 mallctl("stats.mapped", &mi
.arena
, &len
, NULL
, 0);
58 len
= sizeof(mi
.uordblks
);
59 mallctl("stats.allocated", &mi
.uordblks
, &len
, NULL
, 0);
61 mi
.fordblks
= mi
.arena
- mi
.uordblks
;
66 #endif /* USE_STATS_MEMORY */