]>
git.saurik.com Git - apple/xnu.git/blob - libsyscall/os/proc.h
2 * Copyright (c) 2019 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
33 #include <sys/cdefs.h>
34 #include <os/availability.h>
40 * This is for functions that operate on the calling process alone.
46 * @function os_proc_available_memory
49 * Return the number of bytes remaining, at the time of the call, before the
50 * current process will hit its current dirty memory limit.
53 * Developers can query this value efficiently whenever it is needed. The return
54 * value is only a snapshot at the time of the call. Caching the result is not
55 * advised. The result may be instantaneously invalidated by actions taken in
56 * another thread or another framework.
58 * Memory limits can change during the app life cycle. Make sure to check accordingly.
60 * The size returned is not representative of the total memory of the device, it
61 * is the current dirty memory limit minus the dirty memory footprint used at the
64 * This interface allows an app to efficiently consume all available memory resources.
65 * Significant memory use, even under the current memory limit, may still cause
66 * system-wide performance including the termination of other apps and system
67 * processes. Take care to use the minimum amount of memory needed to satisfy the
70 * If you need more information than just the available memory, you can use task_info().
71 * The information returned is equivalent to the task_vm_info.limit_bytes_remaining
72 * field. task_info() is a more expensive call, and will return information such
73 * as your phys_footprint, which is used to calculate the return of this function.
75 * Dirty memory contains data that must be kept in RAM (or the equivalent) even
76 * when unused. It is memory that has been modified.
81 * The remaining bytes. 0 is returned if the calling process is not an app, or
82 * the calling process exceeds its memory limit.
85 API_UNAVAILABLE(macos
) API_AVAILABLE(ios(13.0), tvos(13.0), watchos(6.0), bridgeos(4.0))
87 size_t os_proc_available_memory(void);