mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 17:59:34 +00:00
bug 402763: cycle collect on memory-pressure notification, r/sr=stuart a=schrep
This commit is contained in:
parent
3986314bbc
commit
6699d2a5b3
@ -53,7 +53,7 @@
|
||||
#include "nsIWidget.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsCycleCollector.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
|
||||
#ifdef MOZ_ENABLE_GTK2
|
||||
#include <gdk/gdkx.h>
|
||||
@ -341,8 +341,8 @@ nsDOMWindowUtils::GarbageCollect()
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
#endif
|
||||
|
||||
nsCycleCollector_collect();
|
||||
nsCycleCollector_collect();
|
||||
nsJSContext::CC();
|
||||
nsJSContext::CC();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -281,6 +281,27 @@ nsUserActivityObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsCCMemoryPressureObserver observes the memory-pressure notifications
|
||||
// and forces a cycle collection when it happens.
|
||||
|
||||
class nsCCMemoryPressureObserver : public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCCMemoryPressureObserver, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCCMemoryPressureObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData)
|
||||
{
|
||||
nsJSContext::CC();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
************************** AutoFree ****************************
|
||||
****************************************************************/
|
||||
@ -3620,6 +3641,10 @@ nsJSRuntime::Init()
|
||||
obs->AddObserver(activityObserver, "user-interaction-active", PR_FALSE);
|
||||
obs->AddObserver(activityObserver, "xpcom-shutdown", PR_FALSE);
|
||||
|
||||
nsIObserver* ccMemPressureObserver = new nsCCMemoryPressureObserver();
|
||||
NS_ENSURE_TRUE(ccMemPressureObserver, NS_ERROR_OUT_OF_MEMORY);
|
||||
obs->AddObserver(ccMemPressureObserver, "memory-pressure", PR_FALSE);
|
||||
|
||||
rv = CallGetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &sSecurityManager);
|
||||
|
||||
sIsInitialized = NS_SUCCEEDED(rv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user