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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsStringStats.h"
9 #include "mozilla/IntegerPrintfMacros.h"
10 #include "mozilla/MemoryReporting.h"
24 nsStringStats gStringStats
;
26 nsStringStats::~nsStringStats() {
27 // this is a hack to suppress duplicate string stats printing
28 // in seamonkey as a result of the string code being linked
29 // into seamonkey and libxpcom! :-(
30 if (!mAllocCount
&& !mAdoptCount
) {
34 // Only print the stats if we detect a leak.
35 if (mAllocCount
<= mFreeCount
&& mAdoptCount
<= mAdoptFreeCount
) {
39 printf("nsStringStats\n");
40 printf(" => mAllocCount: % 10d\n", int(mAllocCount
));
41 printf(" => mReallocCount: % 10d\n", int(mReallocCount
));
42 printf(" => mFreeCount: % 10d", int(mFreeCount
));
43 if (mAllocCount
> mFreeCount
) {
44 printf(" -- LEAKED %d !!!\n", mAllocCount
- mFreeCount
);
48 printf(" => mShareCount: % 10d\n", int(mShareCount
));
49 printf(" => mAdoptCount: % 10d\n", int(mAdoptCount
));
50 printf(" => mAdoptFreeCount: % 10d", int(mAdoptFreeCount
));
51 if (mAdoptCount
> mAdoptFreeCount
) {
52 printf(" -- LEAKED %d !!!\n", mAdoptCount
- mAdoptFreeCount
);
58 auto pid
= uintptr_t(_getpid());
59 auto tid
= uintptr_t(GetCurrentThreadId());
61 auto pid
= uintptr_t(getpid());
62 auto tid
= uintptr_t(pthread_self());
65 printf(" => Process ID: %" PRIuPTR
", Thread ID: %" PRIuPTR
"\n", pid
, tid
);