Språk

MemoryBudgetInfo Class

Definition

Memory budget information for an application.

[Android.Runtime.Register("android/content/pm/MemoryBudgetInfo", ApiSince=37, DoNotGenerateAcw=true)]
public sealed class MemoryBudgetInfo : Java.Lang.Object, Android.OS.IParcelable, IDisposable
[<Android.Runtime.Register("android/content/pm/MemoryBudgetInfo", ApiSince=37, DoNotGenerateAcw=true)>]
type MemoryBudgetInfo = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
MemoryBudgetInfo
Attributes
Implements

Remarks

Memory budget information for an application. MemoryBudgetInfo entries are retrieved from <memory-budget> entries in an application's manifest, and can be obtained through PackageManager.getMemoryBudgets.

A MemoryBudgetInfo that is declared in the Android manifest sets a ceiling on the memory available to the package or to a process within the package. MemoryBudgetInfo declarations may appear at the application level and at the process level. The two are independent and neither overrides the other. In practice, however, the smaller budget dominates.

Every MemoryBudgetInfo has a state and a feature; these two attributes determine if and when the MemoryBudgetInfo is applicable.

The state is the operational state of the process or the application, and is one of Foreground, Perceptible, or Background.

The feature selects for device form-factor and is one of Unspecified, TV, Auto, and Watch.

A MemoryBudgetInfo is applicable to a process if its feature is Unspecified or if its feature matches the device's form-factor. A MemoryBudgetInfo applies to a process if it is applicable to the process and the MemoryBudgetInfo state is less than or equal to the operational state of the process. Applications also have state, which is roughly the lowest state of any process running in the application.

A MemoryBudgetInfo declares an upper bound on the amount of memory the process or application may use. The upper bound is computed from three factors:

maxMb is a baseline amount of memory, expressed in MiB. This must be positive.

additionalBytesPerPixel is a scaling factor: bytes per display pixel. This must be non-negative and defaults to zero.

additionalMbPerDensity is a scaling factor: MiB times display density. This must be non-negative and defaults to zero.

The actual limit is calculated as the maxMb value plus the scale factors applied to the default display of the device.

If a process RSS exceeds its declared budget then the kernel will force it to drop memory. This usually means dropping file cache pages but it may also mean that some memory will be moved to swap. In most cases this happens without any impact on the process, but if the process is actively using more memory than the budget limit, the process will slow down as pages are swapped out and then back in. In the limit, the process may ANR.

Android reference for android.content.pm.MemoryBudgetInfo.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Fields

Name Description
FeatureAutomotive
Obsolete.

Indicates that this MemoryBudgetInfo applies to the automotive form factor.

FeatureLeanback
Obsolete.

Indicates that this MemoryBudgetInfo applies to the TV form factor.

FeatureUnspecified
Obsolete.

Indicates that this MemoryBudgetInfo is generic, and can apply to any form factor.

FeatureWatch
Obsolete.

Indicates that this MemoryBudgetInfo applies to the watch form factor.

StateBackground
Obsolete.

Indicates that this MemoryBudgetInfo can apply to a process that is in the background.

StateForeground
Obsolete.

Indicates that this MemoryBudgetInfo can apply to a process that is in the foreground (or in a less important state).

StatePerceptible
Obsolete.

Indicates that this MemoryBudgetInfo can apply to a process that is perceptible (or in a less important state).

Properties

Name Description
AdditionalBytesPerDisplayPixel

Returns the additional bytes per pixel that this MemoryBudgetInfo's limit will be raised by.

AdditionalMbPerDensity

Returns the additional memory (in MiB) that this MemoryBudgetInfo's limit will be raised by, based on the screen density of the device.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator
Feature

Returns the form factor to which this MemoryBudgetInfo applies.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniManagedPeerState (Inherited from JavaObject)
JniPeerMembers
MaxMb

Returns the memory limit (in MiB) that this MemoryBudgetInfo represents.

PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
State

Returns the process state in which this MemoryBudgetInfo applies.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Name Description
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Construct(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
DescribeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DisposeUnlessReferenced() (Inherited from JavaObject)
Equals(Object) (Inherited from JavaObject)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()
Obsolete.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPeerReference(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed() (Inherited from JavaObject)
IJavaPeerable.Finalized() (Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock (Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from JavaObject)
IJavaPeerable.UnregisterFromRuntime()

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to