2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef _OSMEMORYNOTIFICATION_H_
25 #define _OSMEMORYNOTIFICATION_H_
27 #include <sys/cdefs.h>
28 #include <Availability.h>
31 ** OSMemoryNotification.h
33 ** Kernel-generated notification mechanism to alert registered tasks when physical memory
34 ** pressure reaches certain thresholds. Notifications are triggered in both directions
35 ** so clients can manage their memory usage more and less aggressively.
37 ** All of these functions and data types are iOS-only and deprecated in iOS 5.0. Applications
38 ** should listen to UIKit memory warnings (didReceiveMemoryWarning or
39 ** UIApplicationDidReceiveMemoryWarningNotification) instead.
47 ** Opaque type for notification object
49 ** DEPRECATED. Use UIKit memory notification system.
52 typedef struct _OSMemoryNotification
* OSMemoryNotificationRef
;
55 ** Threshold values for notifications
57 ** DEPRECATED. Use UIKit memory notification system.
61 OSMemoryNotificationLevelAny
= -1,
62 OSMemoryNotificationLevelNormal
= 0,
63 OSMemoryNotificationLevelWarning
= 1,
64 OSMemoryNotificationLevelUrgent
= 2,
65 OSMemoryNotificationLevelCritical
= 3
66 } OSMemoryNotificationLevel
;
69 ** Creation routines. Returns the created OSMemoryNotificationRef in the note param.
70 ** returns: 0 on success
71 ** ENOMEM if insufficient memory or resources exists to create the notification object
72 ** EINVAL if the threshold is not a valid notification level
74 ** DEPRECATED. Use UIKit memory notification system.
77 int OSMemoryNotificationCreate(OSMemoryNotificationRef
*note
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA
, __MAC_NA
, __IPHONE_2_0
, __IPHONE_5_0
);
80 ** returns: 0 on success
81 ** EINVAL if the notification is not an initialized notification object
83 ** DEPRECATED. Use UIKit memory notification system.
86 int OSMemoryNotificationDestroy(OSMemoryNotificationRef note
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA
, __MAC_NA
, __IPHONE_2_0
, __IPHONE_5_0
);
89 ** Block waiting for notification
90 ** returns: 0 on success, with the level that triggered the notification in the level param
91 ** EINVAL if the notification object is invalid
92 ** ETIMEDOUT if abstime passes before notification occurs
94 ** 'note' is now ignored.
96 ** DEPRECATED. Use UIKit memory notification system.
98 int OSMemoryNotificationWait(OSMemoryNotificationRef note
, OSMemoryNotificationLevel
*level
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA
, __MAC_NA
, __IPHONE_2_0
, __IPHONE_5_0
);
99 int OSMemoryNotificationTimedWait(OSMemoryNotificationRef note
, OSMemoryNotificationLevel
*level
, const struct timeval
*abstime
) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA
, __MAC_NA
, __IPHONE_2_0
, __IPHONE_5_0
);
102 ** Simple polling interface to detect current memory pressure level
104 ** DEPRECATED. This is not a reliable way to discover the system's memory condition and
105 ** the level is not meaningful in iOS 5.0 and later. Use UIKit memory notification
106 ** system instead, with no need to check the level.
109 OSMemoryNotificationLevel
OSMemoryNotificationCurrentLevel(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA
, __MAC_NA
, __IPHONE_2_0
, __IPHONE_5_0
);
112 ** External notify(3) string for manual notification setup
114 ** DEPRECATED. Use UIKit memory notification system.
117 extern const char *kOSMemoryNotificationName
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA
, __MAC_NA
, __IPHONE_2_0
, __IPHONE_5_0
);
121 #endif /* _OSMEMORYNOTIFICATION_H_ */