2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-06-03 11:02:20 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
/**
|
2001-10-26 04:09:22 +04:00
|
|
|
*
|
2000-06-03 11:02:20 +04:00
|
|
|
* nsIMemory: interface to allocate and deallocate memory. Also provides
|
|
|
|
* for notifications in low-memory situations.
|
2000-09-20 09:44:19 +04:00
|
|
|
*
|
2015-04-01 08:29:55 +03:00
|
|
|
* The frozen exported symbols moz_xmalloc, moz_xrealloc, and free
|
2004-11-12 22:26:37 +03:00
|
|
|
* provide a more efficient way to access XPCOM memory allocation. Using
|
|
|
|
* those symbols is preferred to using the methods on this interface.
|
|
|
|
*
|
2000-09-20 09:44:19 +04:00
|
|
|
* A client that wishes to be notified of low memory situations (for
|
|
|
|
* example, because the client maintains a large memory cache that
|
2001-10-26 04:09:22 +04:00
|
|
|
* could be released when memory is tight) should register with the
|
|
|
|
* observer service (see nsIObserverService) using the topic
|
|
|
|
* "memory-pressure". There are three specific types of notications
|
|
|
|
* that can occur. These types will be passed as the |aData|
|
|
|
|
* parameter of the of the "memory-pressure" notification:
|
|
|
|
*
|
|
|
|
* "low-memory"
|
|
|
|
* This will be passed as the extra data when the pressure
|
|
|
|
* observer is being asked to flush for low-memory conditions.
|
|
|
|
*
|
2013-04-26 05:36:53 +04:00
|
|
|
* "low-memory-ongoing"
|
|
|
|
* This will be passed when we continue to be in a low-memory
|
|
|
|
* condition and we want to flush caches and do other cheap
|
|
|
|
* forms of memory minimization, but heavy handed approaches like
|
|
|
|
* a GC are unlikely to succeed.
|
|
|
|
*
|
|
|
|
* "-no-forward"
|
|
|
|
* This is appended to the above two parameters when the resulting
|
2012-11-08 05:07:57 +04:00
|
|
|
* notification should not be forwarded to the child processes.
|
|
|
|
*
|
2001-10-26 04:09:22 +04:00
|
|
|
* "heap-minimize"
|
|
|
|
* This will be passed as the extra data when the pressure
|
|
|
|
* observer is being asked to flush because of a heap minimize
|
|
|
|
* call.
|
|
|
|
*
|
|
|
|
* "alloc-failure"
|
|
|
|
* This will be passed as the extra data when the pressure
|
|
|
|
* observer has been asked to flush because a malloc() or
|
|
|
|
* realloc() has failed.
|
2000-06-03 11:02:20 +04:00
|
|
|
*/
|
2001-10-26 04:09:22 +04:00
|
|
|
|
2015-03-27 03:10:32 +03:00
|
|
|
[scriptable, uuid(1e004834-6d8f-425a-bc9c-a2812ed43bb7)]
|
2000-06-03 11:02:20 +04:00
|
|
|
interface nsIMemory : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Attempts to shrink the heap.
|
2000-09-20 09:44:19 +04:00
|
|
|
* @param immediate - if true, heap minimization will occur
|
|
|
|
* immediately if the call was made on the main thread. If
|
|
|
|
* false, the flush will be scheduled to happen when the app is
|
|
|
|
* idle.
|
2013-05-16 16:26:55 +04:00
|
|
|
* @throws NS_ERROR_FAILURE if 'immediate' is set an the call
|
2000-09-20 09:44:19 +04:00
|
|
|
* was not on the application's main thread.
|
2000-06-03 11:02:20 +04:00
|
|
|
*/
|
2000-09-20 09:44:19 +04:00
|
|
|
void heapMinimize(in boolean immediate);
|
2000-08-24 12:35:13 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This predicate can be used to determine if we're in a low-memory
|
|
|
|
* situation (what constitutes low-memory is platform dependent). This
|
2001-10-26 04:09:22 +04:00
|
|
|
* can be used to trigger the memory pressure observers.
|
2010-09-03 02:02:06 +04:00
|
|
|
*
|
|
|
|
* DEPRECATED - Always returns false. See bug 592308.
|
2000-08-24 12:35:13 +04:00
|
|
|
*/
|
|
|
|
boolean isLowMemory();
|
2012-10-31 22:59:55 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This predicate can be used to determine if the platform is a "low-memory"
|
|
|
|
* platform. Callers may use this to dynamically tune their behaviour
|
|
|
|
* to favour reduced memory usage at the expense of performance. The value
|
|
|
|
* returned by this function will not change over the lifetime of the process.
|
|
|
|
*/
|
|
|
|
boolean isLowMemoryPlatform();
|
2000-06-03 11:02:20 +04:00
|
|
|
};
|
|
|
|
|