VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/base/nsIMemory.idl@ 44770

最後變更 在這個檔案從44770是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.9 KB
 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#include "nsISupports.idl"
39
40/**
41 *
42 * nsIMemory: interface to allocate and deallocate memory. Also provides
43 * for notifications in low-memory situations.
44 *
45 * A client that wishes to be notified of low memory situations (for
46 * example, because the client maintains a large memory cache that
47 * could be released when memory is tight) should register with the
48 * observer service (see nsIObserverService) using the topic
49 * "memory-pressure". There are three specific types of notications
50 * that can occur. These types will be passed as the |aData|
51 * parameter of the of the "memory-pressure" notification:
52 *
53 * "low-memory"
54 * This will be passed as the extra data when the pressure
55 * observer is being asked to flush for low-memory conditions.
56 *
57 * "heap-minimize"
58 * This will be passed as the extra data when the pressure
59 * observer is being asked to flush because of a heap minimize
60 * call.
61 *
62 * "alloc-failure"
63 * This will be passed as the extra data when the pressure
64 * observer has been asked to flush because a malloc() or
65 * realloc() has failed.
66 *
67 * @status FROZEN
68 */
69
70[scriptable, uuid(59e7e77a-38e4-11d4-8cf5-0060b0fc14a3)]
71interface nsIMemory : nsISupports
72{
73 /**
74 * Allocates a block of memory of a particular size. If the memory
75 * cannot be allocated (because of an out-of-memory condition), null
76 * is returned.
77 *
78 * @param size - the size of the block to allocate
79 * @result the block of memory
80 */
81 [noscript, notxpcom] voidPtr alloc(in size_t size);
82
83 /**
84 * Reallocates a block of memory to a new size.
85 *
86 * @param ptr - the block of memory to reallocate
87 * @param size - the new size
88 * @result the reallocated block of memory
89 *
90 * If ptr is null, this function behaves like malloc.
91 * If s is the size of the block to which ptr points, the first
92 * min(s, size) bytes of ptr's block are copied to the new block.
93 * If the allocation succeeds, ptr is freed and a pointer to the
94 * new block returned. If the allocation fails, ptr is not freed
95 * and null is returned. The returned value may be the same as ptr.
96 */
97 [noscript, notxpcom] voidPtr realloc(in voidPtr ptr,
98 in size_t newSize);
99
100 /**
101 * Frees a block of memory. Null is a permissible value, in which case
102 * nothing happens.
103 *
104 * @param ptr - the block of memory to free
105 */
106 [noscript, notxpcom] void free(in voidPtr ptr);
107
108 /**
109 * Attempts to shrink the heap.
110 * @param immediate - if true, heap minimization will occur
111 * immediately if the call was made on the main thread. If
112 * false, the flush will be scheduled to happen when the app is
113 * idle.
114 * @return NS_ERROR_FAILURE if 'immediate' is set an the call
115 * was not on the application's main thread.
116 */
117 void heapMinimize(in boolean immediate);
118
119 /**
120 * This predicate can be used to determine if we're in a low-memory
121 * situation (what constitutes low-memory is platform dependent). This
122 * can be used to trigger the memory pressure observers.
123 */
124 boolean isLowMemory();
125};
126
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette