Bug 655647 - Allow per-process GC/CC from about:memory. r=dougt

This commit is contained in:
Jiten 2011-09-13 19:53:51 +02:00
parent 6b8124559c
commit dbfb7766e5
6 changed files with 39 additions and 0 deletions

View File

@ -73,6 +73,7 @@
#include "nsWeakReference.h"
#include "nsIScriptError.h"
#include "nsIConsoleService.h"
#include "nsJSEnvironment.h"
#include "History.h"
#include "nsDocShellCID.h"
@ -763,5 +764,20 @@ ContentChild::GetIndexedDBPath()
return *gIndexedDBPath;
}
bool
ContentChild::RecvGarbageCollect()
{
nsJSContext::GarbageCollectNow();
return true;
}
bool
ContentChild::RecvCycleCollect()
{
nsJSContext::GarbageCollectNow();
nsJSContext::CycleCollectNow();
return true;
}
} // namespace dom
} // namespace mozilla

View File

@ -148,6 +148,9 @@ public:
virtual bool RecvActivateA11y();
virtual bool RecvGarbageCollect();
virtual bool RecvCycleCollect();
#ifdef ANDROID
gfxIntSize GetScreenSize() { return mScreenSize; }
#endif

View File

@ -200,6 +200,8 @@ ContentParent::Init()
obs->AddObserver(this, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC, PR_FALSE);
obs->AddObserver(this, "child-memory-reporter-request", PR_FALSE);
obs->AddObserver(this, "memory-pressure", PR_FALSE);
obs->AddObserver(this, "child-gc-request", PR_FALSE);
obs->AddObserver(this, "child-cc-request", PR_FALSE);
#ifdef ACCESSIBILITY
obs->AddObserver(this, "a11y-init-or-shutdown", PR_FALSE);
#endif
@ -304,6 +306,8 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
obs->RemoveObserver(static_cast<nsIObserver*>(this), "memory-pressure");
obs->RemoveObserver(static_cast<nsIObserver*>(this), "child-memory-reporter-request");
obs->RemoveObserver(static_cast<nsIObserver*>(this), NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC);
obs->RemoveObserver(static_cast<nsIObserver*>(this), "child-gc-request");
obs->RemoveObserver(static_cast<nsIObserver*>(this), "child-cc-request");
#ifdef ACCESSIBILITY
obs->RemoveObserver(static_cast<nsIObserver*>(this), "a11y-init-or-shutdown");
#endif
@ -749,6 +753,12 @@ ContentParent::Observe(nsISupports* aSubject,
else if (!strcmp(aTopic, "child-memory-reporter-request")) {
SendPMemoryReportRequestConstructor();
}
else if (!strcmp(aTopic, "child-gc-request")){
SendGarbageCollect();
}
else if (!strcmp(aTopic, "child-cc-request")){
SendCycleCollect();
}
#ifdef ACCESSIBILITY
// Make sure accessibility is running in content process when accessibility
// gets initiated in chrome process.

View File

@ -105,6 +105,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../../xpcom/base \
-I$(srcdir)/../indexedDB \
-I$(topsrcdir)/extensions/cookie \
-I$(topsrcdir)/dom/base \
$(NULL)
DEFINES += -DBIN_SUFFIX='"$(BIN_SUFFIX)"'

View File

@ -129,6 +129,9 @@ child:
FlushMemory(nsString reason);
GarbageCollect();
CycleCollect();
/**
* Start accessibility engine in content process.
*/

View File

@ -144,6 +144,9 @@ function $(n)
function doGlobalGC()
{
Cu.forceGC();
var os = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
os.notifyObservers(null, "child-gc-request", null);
update();
}
@ -152,6 +155,9 @@ function doCC()
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.cycleCollect();
var os = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
os.notifyObservers(null, "child-cc-request", null);
update();
}