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 the current status of the memory.
Parameters
Name | Required | Type | Description |
---|---|---|---|
subscribe | Optional | Boolean | Subscribe for notifications. Possible values are:
Default: false |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
applications | Required | Object array: application | Indicates the list of running applications. |
system | Required | Object: system | Indicates the current system information. |
threshold | Required | Object: threshold | Indicates the threshold values. |
subscribed | Required | Boolean | Subscribe for notifications. Possible values are:
|
returnValue | Required | Boolean | Indicates the status of the 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
Example code
# luna-send -f -i luna://com.webos.service.memorymanager/getMemoryStatus '{
"subscribe":true
}'
Response:
{
"subscribed": true,
"returnValue": true,
"system": {
"level": "normal",
"available": 5995,
"total": 7538
},
"threshold": {
"low": {
"enter": 250,
"exit": 280
},
"critical": {
"enter": 100,
"exit": 130
}
},
"applications": [
{
"appId": "com.webos.app.test.enact",
"instanceId": "56a536ae-bf17-45f3-a255-4ba521b9081e1",
"pid": 2499,
"status": "foreground",
"type": "web",
"pss": "0"
}
]
}
getManagerEvent
Description
Subscribe to be notified when a MemoryManager internal event occurs.
Parameters
Name | Required | Type | Description |
---|---|---|---|
type | Required | String | Indicates the memory manager event type. Possible values are:
|
subscribe | Required | Boolean | Indicates if subscribed for notifications. Possible values are:
|
Call Returns
Name | Required | Type | Description |
---|---|---|---|
subscribed | Required | Boolean | Indicates if subscribed to get notifications.
|
returnValue | Required | Boolean | Indicates the status of the 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 | Indicates the app ID. Note: The value exists only for 'killing' type event. |
type | Required | String | Memory Manager Event Type.
|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
subscribed | Required | Boolean | Indicates if subscribed to get notifications.
|
instanceId | Optional | String | Indicates the instance ID. |
Example
Example code
# luna-send -f -i luna://com.webos.service.memorymanager/getManagerEvent '{
"type":"killing",
"subscribe":true
}'
Response:
{
"subscribed": true,
"returnValue": true
}
Subscription response:
{
"subscribed": true,
"returnValue": true,
"instanceId": "339164a1-2d8d-4d93-819b-427b5c12a75b1",
"id": "com.webos.app.test.enact",
"type": "killing"
}
requireMemory
Description
Requests for the memory that is required to launch an application.
Note: This method is called by the SAM module when it is about to launch an application.
Parameters
Name | Required | Type | Description |
---|---|---|---|
requiredMemory | Required | Number | Indicates the amount of memory required to launch the application. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. This method always returns true. |
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
Example code
# luna-send -f -n 1 luna://com.webos.service.memorymanager/requireMemory '{
"requiredMemory":120
}'
Response:
{
"returnValue":true
}
sysInfo
Description
Provides a way to account for memory usage.
Parameters
None
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the 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. |
System View | Required | Object array: system_view | Indicates the system level memory information. |
PSS View | Required | Object array: pss_view | Indicates the PSS information of services and applications per session. |
Example
Example code
# luna-send -f -n 1 luna://com.webos.service.memorymanager/sysInfo '{ }'
Response:
{
"returnValue": true,
"System View": [
{
"Essential": [
"BSP : 669224 K",
"Custom Kernel : 513466 K",
"Kernel : 508892 K",
"System PSS : 750928 K"
]
},
{
"Foreground": [
"Foreground PSS : 90490 K"
]
},
{
"Performance": [
"Cached Kernel : 304672 K",
"Cached PSS : 0 K"
]
},
{
"Free": [
"Free : 5550936 K"
]
}
],
"PSS View": [
{
"driver0": [
{
"System": [
"55096 K: maliit-server.service (pid 2016)",
"39725 K: webapp-mgr.service (pid 1631)",
"...",
"297 K: maliit-server.service (pid 1995)"
]
},
{
"Foreground": [
"30414 K: com.webos.app.firstuse (pid 1835)"
]
}
]
},
{
"guest0": [
{
"System": [
"54682 K: maliit-server.service (pid 1987)",
"45024 K: webapp-mgr.service (pid 1514)",
"...",
"291 K: maliit-server.service (pid 1957)"
]
},
{
"Foreground": [
"30119 K: com.webos.app.firstuse (pid 1837)"
]
}
]
},
{
"guest1": [
{
"System": [
"54676 K: maliit-server.service (pid 2064)",
"42434 K: webapp-mgr.service (pid 1556)",
"...",
"285 K: maliit-server.service (pid 2030)"
]
},
{
"Foreground": [
"29957 K: com.webos.app.firstuse (pid 1834)"
]
}
]
},
{
"host": [
{
"System": [
"43910 K: surface-manager-daemon.service (pid 1010)",
"5957 K: pulseaudio.service (pid 1040)",
"...",
"163 K: qrtr-ns.service (pid 477)"
]
}
]
}
]
}
Objects
system
Indicates the current memory information.
Name | Required | Type | Description |
---|---|---|---|
available | Required | Number | Indicates the available memory. |
total | Required | Number | Indicates the total memory. |
level | Required | String | Indicates the current memory status. Possible values are:
|
application
Indicates the application memory description.
Name | Required | Type | Description |
---|---|---|---|
appId | Required | String | Indicates the application ID. |
status | Required | String | Indicates the status of the application. Possible values are:
|
pid | Required | Number | Indicates the process ID. |
time | Required | Number | Indicates the timestamp about 'foreground' apps. |
type | Required | String | Indicates the application type. Possible values are:
|
threshold
Indicates the memory level threshold.
Name | Required | Type | Description |
---|---|---|---|
low | Required | Object: threshold_item | Indicates the low threshold. |
critical | Required | Object: threshold_item | Indicates the critical threshold. |
threshold_item
Indicates the threshold item.
Name | Required | Type | Description |
---|---|---|---|
enter | Required | Number | Indicates the enter threshold. |
exit | Required | Number | Indicates the exit threshold. |
system_view
Provides system-level memory information.
Name | Required | Type | Description |
---|---|---|---|
Essential | Required | String array | Indicates the essential memory to run the system. Values are:
|
Foreground | Required | String array | Indicates the memory of processes that interacts with users. Value is:
|
Free | Required | String array | Indicates the free memory. Value is:
|
Performance | Required | String array | Indicates the memory that does not interact with users, but memory for performance improvement. Values are:
|
pss_view
PSS information of services and applications per session
Name | Required | Type | Description |
---|---|---|---|
host | Required | Object array | Indicates the PSS information on host session. |
driver0 | Optional | Object array | Indicates the PSS information on driver0 session. |
guest0 | Optional | Object array | Indicates the PSS information on guest0 session. |
guest1 | Optional | Object array | Indicates the PSS information on guest1 session. |
Signals/Events
levelChanged
Indicates the LS signal for memory level change. The signal is always sent whenever memory level is changed.
Call Returns
Name | Required | Type | Description |
---|---|---|---|
previous | Required | Object array | Indicates the previous memory level. |
current | Required | Object array | Indicates the 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 |