mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 696690 - Memory reporter for the startup cache. r=tglek.
This commit is contained in:
parent
a0596c9180
commit
ec7275aedd
@ -234,6 +234,11 @@ nsresult nsZipHandle::Init(nsZipArchive *zip, const char *entry,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt64 nsZipHandle::SizeOfMapping()
|
||||
{
|
||||
return mLen;
|
||||
}
|
||||
|
||||
nsZipHandle::~nsZipHandle()
|
||||
{
|
||||
if (mMap) {
|
||||
@ -775,6 +780,14 @@ MOZ_WIN_MEM_TRY_BEGIN
|
||||
MOZ_WIN_MEM_TRY_CATCH(return nsnull)
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
// nsZipArchive::SizeOfMapping
|
||||
//---------------------------------------------
|
||||
PRInt64 nsZipArchive::SizeOfMapping()
|
||||
{
|
||||
return mFd ? mFd->SizeOfMapping() : 0;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// nsZipArchive constructor and destructor
|
||||
//------------------------------------------
|
||||
|
@ -221,6 +221,12 @@ public:
|
||||
*/
|
||||
const PRUint8* GetData(nsZipItem* aItem);
|
||||
|
||||
/**
|
||||
* Gets the amount of memory taken up by the archive's mapping.
|
||||
* @return the size
|
||||
*/
|
||||
PRInt64 SizeOfMapping();
|
||||
|
||||
private:
|
||||
//--- private members ---
|
||||
|
||||
@ -382,6 +388,8 @@ public:
|
||||
NS_METHOD_(nsrefcnt) AddRef(void);
|
||||
NS_METHOD_(nsrefcnt) Release(void);
|
||||
|
||||
PRInt64 SizeOfMapping();
|
||||
|
||||
protected:
|
||||
const PRUint8 * mFileData; /* pointer to mmaped file */
|
||||
PRUint32 mLen; /* length of file and memory mapped area */
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "nsIClassInfo.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIOutputStream.h"
|
||||
@ -81,6 +82,22 @@
|
||||
#define SC_WORDSIZE "8"
|
||||
#endif
|
||||
|
||||
static PRInt64
|
||||
GetStartupCacheSize()
|
||||
{
|
||||
mozilla::scache::StartupCache* sc = mozilla::scache::StartupCache::GetSingleton();
|
||||
return sc ? sc->SizeOfMapping() : 0;
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(StartupCache,
|
||||
"explicit/startup-cache",
|
||||
KIND_NONHEAP,
|
||||
nsIMemoryReporter::UNITS_BYTES,
|
||||
GetStartupCacheSize,
|
||||
"Memory used to hold the startup cache. This "
|
||||
"memory is backed by a file and is likely to be "
|
||||
"swapped out shortly after start-up.");
|
||||
|
||||
namespace mozilla {
|
||||
namespace scache {
|
||||
|
||||
@ -120,7 +137,8 @@ StartupCache* StartupCache::gStartupCache;
|
||||
bool StartupCache::gShutdownInitiated;
|
||||
|
||||
StartupCache::StartupCache()
|
||||
: mArchive(NULL), mStartupWriteInitiated(false), mWriteThread(NULL) {}
|
||||
: mArchive(NULL), mStartupWriteInitiated(false), mWriteThread(NULL),
|
||||
mMemoryReporter(nsnull) { }
|
||||
|
||||
StartupCache::~StartupCache()
|
||||
{
|
||||
@ -134,6 +152,8 @@ StartupCache::~StartupCache()
|
||||
WaitOnWriteThread();
|
||||
WriteToDisk();
|
||||
gStartupCache = nsnull;
|
||||
(void)::NS_UnregisterMemoryReporter(mMemoryReporter);
|
||||
mMemoryReporter = nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -206,6 +226,10 @@ StartupCache::Init()
|
||||
NS_WARNING("Failed to load startupcache file correctly, removing!");
|
||||
InvalidateCache();
|
||||
}
|
||||
|
||||
mMemoryReporter = new NS_MEMORY_REPORTER_NAME(StartupCache);
|
||||
(void)::NS_RegisterMemoryReporter(mMemoryReporter);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -308,6 +332,12 @@ StartupCache::PutBuffer(const char* id, const char* inbuf, PRUint32 len)
|
||||
return ResetStartupWriteTimer();
|
||||
}
|
||||
|
||||
PRInt64
|
||||
StartupCache::SizeOfMapping()
|
||||
{
|
||||
return mArchive ? mArchive->SizeOfMapping() : 0;
|
||||
}
|
||||
|
||||
struct CacheWriteHolder
|
||||
{
|
||||
nsCOMPtr<nsIZipWriter> writer;
|
||||
|
@ -95,6 +95,8 @@
|
||||
* provide some convenience in writing out data.
|
||||
*/
|
||||
|
||||
class nsIMemoryReporter;
|
||||
|
||||
namespace mozilla {
|
||||
namespace scache {
|
||||
|
||||
@ -148,6 +150,8 @@ public:
|
||||
static StartupCache* GetSingleton();
|
||||
static void DeleteSingleton();
|
||||
|
||||
PRInt64 SizeOfMapping();
|
||||
|
||||
private:
|
||||
StartupCache();
|
||||
~StartupCache();
|
||||
@ -178,6 +182,8 @@ private:
|
||||
#ifdef DEBUG
|
||||
nsTHashtable<nsISupportsHashKey> mWriteObjectMap;
|
||||
#endif
|
||||
|
||||
nsIMemoryReporter* mMemoryReporter;
|
||||
};
|
||||
|
||||
// This debug outputstream attempts to detect if clients are writing multiple
|
||||
|
Loading…
Reference in New Issue
Block a user