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

(click to expand)

N/A


Open All


getMemoryStatus

Description

Provides current status of the memory.

Parameters

Name

Required

Type

Description

subscribeOptionalBoolean

Subscribe for notifications. Possible values are:

  • true - Get notifications
  • false - Notifications are not required

Default value: false

Call Returns

Name

Required

Type

Description

applicationsRequiredObject array: application

List of running applications.

systemRequiredObject: system

Current system information.

thresholdRequiredObject: threshold

Threshold values.

subscribedRequiredBoolean

Indicates if subscribed to get notified.

  • true - Subscribed for changes
  • false - Not subscribed
returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check "errorText" field for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

root@raspberrypi3:~# luna-send -f -i luna://com.webos.service.memorymanager/getMemoryStatus '{ "subscribe":true }'

 

Returns:
{
    "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

typeRequiredString

Memory Manager Event Type.

  • 'killing' : application killing event when memory level is under 'low'
subscribeRequiredBoolean

Subscribe for notifications. Possible values are:

  • true - Get notifications
  • false - Notifications are not required

​This is subscription API so value MUST true.

Call Returns

Name

Required

Type

Description

subscribedRequiredBoolean

Indicates if subscribed to get notified.

  • true - Subscribed for changes
  • false - Not subscribed
returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check "errorText" field for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Subscription Returns

Name

Required

Type

Description

idOptionalString

The app ID. The value exists only for 'killing' type event.

typeRequiredString

Memory Manager Event Type.

  • 'killing' : application killing event when memory level is under 'low'
returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check "errorText" field for details.
subscribedRequiredBoolean

Indicates if subscribed to get notified.

  • true - Subscribed for changes
  • false - Not subscribed

Example

root@raspberrypi3:~# luna-send -f -i luna://com.webos.service.memorymanager/getManagerEvent '{ "type": "killing", "subscribe":true }'

 

Returns:
{
    "subscribed": true,
    "returnValue": true
}


Subscription returns:
{
    "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

requiredMemoryRequiredNumber

Amount of memory required to launch the application.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check "errorText" field for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

root@raspberrypi3:~# luna-send -f -n 1 luna://com.webos.service.memorymanager/requireMemory '{ "requiredMemory": 120 }'

 

Returns:
{
    "returnValue": true
}


Objects

system

Current memory information

Name

Required

Type

Description

freeRequiredNumber

Free memory. 

totalRequiredNumber

Total memory.

levelRequiredString

Current memory status. Possible values are:

  • normal
  • low
  • critical

application

application memory description.

Name

Required

Type

Description

appIdRequiredString

Application ID.

statusRequiredString

Status of application. Possible values are:

  • foreground
  • background
  • unknown
  • ....
pidRequiredNumber

Process ID.

timeRequiredNumber

Timestamp about 'foreground' apps.

typeRequiredString

Application type. Possible values are:

  • web
  • native
  • qml
  • unknown

threshold

memory level threshold

Name

Required

Type

Description

lowRequiredObject: threshold_item

Low threshold.

criticalRequiredObject: threshold_item

Critical threshold.

threshold_item

Threshold Item.

Name

Required

Type

Description

enterRequiredNumber

Enter threshold.

exitRequiredNumber

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

previousRequiredNumber

Previous memory level.

currentRequiredNumber

Current memory level.


ERROR REFERENCES

Error Code

Error Text

Error Description

1Unknown Error

Unknown Error

2Wrong Json Format Error

Wrong Json Format Error

3No Required Parameters Error

No Required Parameters Error

4Invalid Parameters Error

Invalid Parameters Error

5LS2 Internal Error

LS2 Internal Error

6Unsupported API

Unsupported API


Except as noted, this content is licensed under Creative Commons Attribution 4.0 and sample code is licensed under Apache License 2.0.