com.webos.service.memorymanager
API Summary
Manages applications to ensure that the system does not run into kernel-Out-Of-Memory situation. This is achieved by killing applications that are in the background when we reach low memory conditions.
The goal of MemoryManager:
- To maintain the state of memory usage across the app
- To prevent running OOM (out of memory)
- To correct the situation where memory runs out.
Overview of the API
N/A
Methods
getMemoryStatus
Description
Provides current status of the memory.
Parameters
Name | Required | Type | Description |
---|---|---|---|
subscribe | Optional | Boolean | Subscribe for notifications. Possible values are:
Default value: false |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
applications | Required | Object array: application | List of running applications. |
system | Required | Object: system | Current system information. |
threshold | Required | Object: threshold | Threshold values. |
subscribed | Required | Boolean | Indicates if subscribed to get notified.
|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example
# luna-send -f -i luna://com.webos.service.memorymanager/getMemoryStatus '{ "subscribe":true }'
Response:
{
"applications": [
{
"appId": "com.webos.app.test.enact",
"status": "foreground",
"pid": 2528,
"time": 11147,
"type": "web"
}
],
"system": {
"free": 386,
"total": 681,
"level": "normal"
},
"threshold": {
"low": {
"enter": 200,
"exit": 250
},
"critical": {
"enter": 100,
"exit": 150
}
},
"returnValue": true,
"subscribed": true
}
getManagerEvent
Description
Subscribe to be notified when a MemoryManager internal event occurs.
Parameters
Name | Required | Type | Description |
---|---|---|---|
type | Required | String | Memory Manager Event Type.
|
subscribe | Required | Boolean | Subscribe for notifications. Possible values are:
This is subscription API so value MUST true. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
subscribed | Required | Boolean | Indicates if subscribed to get notified.
|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Subscription Returns
Name | Required | Type | Description |
---|---|---|---|
id | Optional | String | The app ID. The value exists only for 'killing' type event. |
type | Required | String | Memory Manager Event Type.
|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
subscribed | Required | Boolean | Indicates if subscribed to get notified.
|
Example
# luna-send -f -i luna://com.webos.service.memorymanager/getManagerEvent '{ "type": "killing", "subscribe":true }'
Response:
{
"subscribed": true,
"returnValue": true
}
Subscription Return:
{
"id": "com.webos.app.test.enact",
"type": "killing",
"subscribed": true,
"returnValue": true
}
requireMemory
Description
Requests for the memory that is required to launch an application.
Note: This method is called by SAM when it about to launch an application.
Parameters
Name | Required | Type | Description |
---|---|---|---|
requiredMemory | Required | Number | Amount of memory required to launch the application. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example
# luna-send -f -n 1 luna://com.webos.service.memorymanager/requireMemory '{ "requiredMemory": 120 }'
Response:
{
"returnValue": true
}
Objects
system
Current memory information
Name | Required | Type | Description |
---|---|---|---|
free | Required | Number | Free memory. |
total | Required | Number | Total memory. |
level | Required | String | Current memory status. Possible values are:
|
application
application memory description.
Name | Required | Type | Description |
---|---|---|---|
appId | Required | String | Application ID. |
status | Required | String | Status of application. Possible values are:
|
pid | Required | Number | Process ID. |
time | Required | Number | Timestamp about 'foreground' apps. |
type | Required | String | Application type. Possible values are:
|
threshold
memory level threshold
Name | Required | Type | Description |
---|---|---|---|
low | Required | Object: threshold_item | Low threshold. |
critical | Required | Object: threshold_item | Critical threshold. |
threshold_item
Threshold Item.
Name | Required | Type | Description |
---|---|---|---|
enter | Required | Number | Enter threshold. |
exit | Required | Number | Exit threshold. |
Signals/Events
levelChanged
LS signal for memory level change. The signal is always sent whenever memory level is changed.
Call Returns
Name | Required | Type | Description |
---|---|---|---|
previous | Required | Number | Previous memory level. |
current | Required | Number | Current memory level. |
API Error Codes Reference
Error Code | Error Text | Error Description |
---|---|---|
1 | Unknown Error | Unknown Error |
2 | Wrong Json Format Error | Wrong Json Format Error |
3 | No Required Parameters Error | No Required Parameters Error |
4 | Invalid Parameters Error | Invalid Parameters Error |
5 | LS2 Internal Error | LS2 Internal Error |
6 | Unsupported API | Unsupported API |