no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / memory / mozjemalloc_info / MozjemallocInfo.cpp
blob0795be804718ed01409c994c4a8e17f055d3323b
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include <stdio.h>
8 #include <stdlib.h>
10 #include "mozmemory.h"
13 * Print the configured size classes which we can then use to update
14 * documentation.
16 int main() {
17 jemalloc_stats_t stats;
19 const size_t num_bins = jemalloc_stats_num_bins();
20 const size_t MAX_NUM_BINS = 100;
21 if (num_bins > MAX_NUM_BINS) {
22 fprintf(stderr, "Exceeded maximum number of jemalloc stats bins");
23 return 1;
25 jemalloc_bin_stats_t bin_stats[MAX_NUM_BINS] = {{0}};
26 jemalloc_stats(&stats, bin_stats);
28 printf("Page size: %5zu\n", stats.page_size);
29 printf("Chunk size: %5zuKiB\n", stats.chunksize / 1024);
31 printf("Quantum: %5zu\n", stats.quantum);
32 printf("Quantum max: %5zu\n", stats.quantum_max);
33 printf("Sub-page max: %5zu\n", stats.page_size / 2);
34 printf("Large max: %5zuKiB\n", stats.large_max / 1024);
36 printf("\nBin stats:\n");
37 for (unsigned i = 0; i < num_bins; i++) {
38 auto& bin = bin_stats[i];
39 if (bin.size) {
40 printf(" Bin %5zu has runs of %3zuKiB\n", bin.size,
41 bin.bytes_per_run / 1024);
45 return EXIT_SUCCESS;