Bug 1407810 - DDMediaLogs::SizeOf accounts for shallow message queue size - r=jwwang

MozReview-Commit-ID: 9irARpytVoh

--HG--
extra : rebase_source : a18db325396ca50b9272559b3dcbb7ccc3d63f87
This commit is contained in:
Gerald Squelart 2017-10-17 16:10:05 +11:00
parent e18e0d36a5
commit 5d9cad55f1
2 changed files with 16 additions and 1 deletions

View File

@ -305,6 +305,9 @@ size_t
DDMediaLogs::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t size = aMallocSizeOf(this) +
// This will usually be called after processing, so negligible
// external data should still be present in the queue.
mMessagesQueue.ShallowSizeOfExcludingThis(aMallocSizeOf) +
mLifetimes.SizeOfExcludingThis(aMallocSizeOf) +
mMediaLogs.ShallowSizeOfExcludingThis(aMallocSizeOf) +
mObjectLinks.ShallowSizeOfExcludingThis(aMallocSizeOf) +
@ -676,7 +679,8 @@ DDMediaLogs::ProcessLog()
ProcessBuffer();
FulfillPromises();
CleanUpLogs();
DDL_INFO("DDMediaLog size: %zu", SizeOfIncludingThis(moz_malloc_size_of));
DDL_INFO("ProcessLog() completed - DDMediaLog size: %zu",
SizeOfIncludingThis(moz_malloc_size_of));
}
nsresult
@ -693,6 +697,8 @@ DDMediaLogs::DispatchProcessLog(const MutexAutoLock& aProofOfLock)
nsresult
DDMediaLogs::DispatchProcessLog()
{
DDL_INFO("DispatchProcessLog() - Yet-unprocessed message buffers: %d",
mMessagesQueue.LiveBuffersStats().mCount);
MutexAutoLock lock(mMutex);
return DispatchProcessLog(lock);
}

View File

@ -8,6 +8,7 @@
#define mozilla_MultiWriterQueue_h_
#include "mozilla/Atomics.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Move.h"
#include "mozilla/Mutex.h"
#include "prthread.h"
@ -253,6 +254,12 @@ public:
}
}
// Size of all buffers (used, or recyclable), excluding external data.
size_t ShallowSizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
return mAllocatedBuffersStats.Count() * sizeof(Buffer);
}
struct CountAndWatermark
{
int mCount;
@ -500,6 +507,8 @@ private:
{
}
int Count() const { return int(mCount); }
CountAndWatermark Get() const
{
return CountAndWatermark{ int(mCount), int(mWatermark) };