Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions) Summary: [Constants](https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#constants) \| [Inherited Constants](https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#inhconstants) \| [Fields](https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#lfields) \| [Methods](https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#inhmethods)

# MemoryBudgetInfo

*** ** * ** ***


`
public

final

class
MemoryBudgetInfo
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/os/Parcelable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.content.pm.MemoryBudgetInfo |

<br />

*** ** * ** ***

Memory budget information for an application. `MemoryBudgetInfo` entries are retrieved from
\<memory-budget\> entries in an application's manifest, and can be obtained through
`https://developer.android.com/reference/android/content/pm/PackageManager#getMemoryBudgets(android.content.pm.ApplicationInfo)`.


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.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#FEATURE_AUTOMOTIVE` Indicates that this `MemoryBudgetInfo` applies to the automotive form factor. |
| `int` | `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#FEATURE_LEANBACK` Indicates that this `MemoryBudgetInfo` applies to the TV form factor. |
| `int` | `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#FEATURE_UNSPECIFIED` Indicates that this `MemoryBudgetInfo` is generic, and can apply to any form factor. |
| `int` | `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#FEATURE_WATCH` Indicates that this `MemoryBudgetInfo` applies to the watch form factor. |
| `int` | `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#STATE_BACKGROUND` Indicates that this `MemoryBudgetInfo` can apply to a process that is in the background. |
| `int` | `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#STATE_FOREGROUND` Indicates that this `MemoryBudgetInfo` can apply to a process that is in the foreground (or in a less important state). |
| `int` | `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#STATE_PERCEPTIBLE` Indicates that this `MemoryBudgetInfo` can apply to a process that is perceptible (or in a less important state). |

### Inherited constants

From interface `https://developer.android.com/reference/android/os/Parcelable` `int` `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR`

Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that
the Parcelable object's flattened representation includes a file descriptor.


`int` `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`

Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written
is a return value, that is the result of a function such as
"`Parcelable someFunction()`",
"`void someFunction(out Parcelable)`", or
"`void someFunction(inout Parcelable)`".


| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo>` | `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#CREATOR` |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` boolean` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) ` Indicates whether some other object is "equal to" this one. |
| ` long` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#getAdditionalBytesPerDisplayPixel()() ` Returns the additional bytes per pixel that this `MemoryBudgetInfo`'s limit will be raised by. |
| ` long` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#getAdditionalMbPerDensity()() ` Returns the additional memory (in MiB) that this `MemoryBudgetInfo`'s limit will be raised by, based on the screen density of the device. |
| ` int` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#getFeature()() ` Returns the form factor to which this `MemoryBudgetInfo` applies. |
| ` long` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#getMaxMb()() ` Returns the memory limit (in MiB) that this `MemoryBudgetInfo` represents. |
| ` int` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#getState()() ` Returns the process state in which this `MemoryBudgetInfo` applies. |
| ` int` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#hashCode()() ` Returns a hash code value for the object. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#toString()() ` Returns a string representation of the object. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

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


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

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


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

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


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

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


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

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


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

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


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


From interface `

https://developer.android.com/reference/android/os/Parcelable

` `
abstract


int` `
https://developer.android.com/reference/android/os/Parcelable#describeContents()()
`

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


`
abstract


void` `
https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags)
`

Flatten this object in to a Parcel.


## Constants

### FEATURE_AUTOMOTIVE

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int FEATURE_AUTOMOTIVE
```

Indicates that this `MemoryBudgetInfo` applies to the automotive form factor.

<br />

Constant Value:

1
(0x00000001)


### FEATURE_LEANBACK

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int FEATURE_LEANBACK
```

Indicates that this `MemoryBudgetInfo` applies to the TV form factor.

<br />

Constant Value:

2
(0x00000002)


### FEATURE_UNSPECIFIED

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int FEATURE_UNSPECIFIED
```

Indicates that this `MemoryBudgetInfo` is generic, and can apply to any form
factor. This is the default if "feature" is not specified in the manifest.

<br />

Constant Value:

0
(0x00000000)


### FEATURE_WATCH

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int FEATURE_WATCH
```

Indicates that this `MemoryBudgetInfo` applies to the watch form factor.

<br />

Constant Value:

3
(0x00000003)


### STATE_BACKGROUND

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int STATE_BACKGROUND
```

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

<br />

Constant Value:

300
(0x0000012c)


### STATE_FOREGROUND

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int STATE_FOREGROUND
```

Indicates that this `MemoryBudgetInfo` can apply to a process that is in the
foreground (or in a less important state). This is the default if "state" is not
specified in the manifest.

<br />

Constant Value:

100
(0x00000064)


### STATE_PERCEPTIBLE

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int STATE_PERCEPTIBLE
```

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

<br />

Constant Value:

200
(0x000000c8)


## Fields

### CREATOR

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final Creator<MemoryBudgetInfo> CREATOR
```

<br />

<br />

## Public methods

### describeContents

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`,
the return value of this method must include the
`https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### equals

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public boolean equals (Object o)
```

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


The `equals` method implements an equivalence relation
on non-null object references:

- It is *reflexive*: for any non-null reference value `x`, `x.equals(x)` should return `true`.
- It is *symmetric*: for any non-null reference values `x` and `y`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`.
- It is *transitive*: for any non-null reference values `x`, `y`, and `z`, if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.
- It is *consistent*: for any non-null reference values `x` and `y`, multiple invocations of `x.equals(y)` consistently return `true` or consistently return `false`, provided no information used in `equals` comparisons on the objects is modified.
- For any non-null reference value `x`, `x.equals(null)` should return `false`.


An equivalence relation partitions the elements it operates on
into *equivalence classes*; all the members of an
equivalence class are equal to each other. Members of an
equivalence class are substitutable for each other, at least
for some purposes.

<br />

| Parameters ||
|---|---|
| `o` | `Object`: the reference object with which to compare. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### getAdditionalBytesPerDisplayPixel

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public long getAdditionalBytesPerDisplayPixel ()
```

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

<br />

| Returns ||
|---|---|
| `long` | The additionalBytesPerDisplayPixel attribute. Value is between 0 and `https://developer.android.com/` inclusive <br /> |

### getAdditionalMbPerDensity

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public long getAdditionalMbPerDensity ()
```

Returns the additional memory (in MiB) that this `MemoryBudgetInfo`'s limit will
be raised by, based on the screen density of the device. The formula used for
calculating the additional memory is (N \* { ldpi=0.75, mdpi=1.0, hdpi=1.5, xhdpi=2... }).

<br />

| Returns ||
|---|---|
| `long` | The additionalMbPerDensity attribute. Value is between 0 and `https://developer.android.com/` inclusive <br /> |

### getFeature

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public int getFeature ()
```

Returns the form factor to which this `MemoryBudgetInfo` applies.

<br />

| Returns ||
|---|---|
| `int` | The form factor to which this `MemoryBudgetInfo` applies. Value is one of the following: - `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#FEATURE_UNSPECIFIED` - `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#FEATURE_AUTOMOTIVE` - `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#FEATURE_LEANBACK` - `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#FEATURE_WATCH` |

### getMaxMb

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public long getMaxMb ()
```

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

<br />

| Returns ||
|---|---|
| `long` | The memory limit (in MiB) that this `MemoryBudgetInfo` represents. Value is between 1 and `https://developer.android.com/` inclusive <br /> |

### getState

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public int getState ()
```

Returns the process state in which this `MemoryBudgetInfo` applies.

<br />

| Returns ||
|---|---|
| `int` | The process state in which this `MemoryBudgetInfo` applies. Value is one of the following: - `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#STATE_FOREGROUND` - `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#STATE_PERCEPTIBLE` - `https://developer.android.com/reference/android/content/pm/MemoryBudgetInfo#STATE_BACKGROUND` |

### hashCode

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public int hashCode ()
```

Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
`https://developer.android.com/reference/java/util/HashMap`.


The general contract of `hashCode` is:

- Whenever it is invoked on the same object more than once during an execution of a Java application, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce the same integer result.
- It is *not* required that if two objects are unequal according to the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

<br />

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object. <br /> |

### toString

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### writeToParcel

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |