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

ACG: memorymanager.query

Description

Provides the 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: false

Call Returns

Name

Required

Type

Description

applicationsRequiredObject array: application

Indicates the list of running applications.

systemRequiredObject: system

Indicates the current system information.

thresholdRequiredObject: threshold

Indicates the threshold values.

subscribedRequiredBoolean

Subscribe for notifications.

Possible values are:

  • true: Get notifications
  • false: Notifications are not required
returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Method execution is successful
  • false: Method executed with errors. Check the errorCode and errorText 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

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

ACG: memorymanager.query

Description

Subscribe to be notified when a MemoryManager internal event occurs.

Parameters

Name

Required

Type

Description

typeRequiredString

Indicates the memory manager event type.

Possible values are:

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

Indicates if subscribed for notifications.

Possible values are:

  • true: Subscribe for notifications
  • false: Notifications are not required

Call Returns

Name

Required

Type

Description

subscribedRequiredBoolean

Indicates if subscribed to get notifications.

  • true: Subscribed for notifications
  • false: Not subscribed
returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Method execution is successful
  • false: Method executed with errors. Check the errorCode and errorText 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

Indicates the app ID.

Note: 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 the operation.

Possible values are:

  • true: Method execution is successful
  • false: Method executed with errors. Check the errorCode and errorText for details.
subscribedRequiredBoolean

Indicates if subscribed to get notifications.

  • true: Subscribed for notifications
  • false: Not subscribed
instanceIdOptionalString

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

ACG: memorymanager.management

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

Indicates the amount of memory required to launch the application.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the 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

Example code

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

Response:

{
   "returnValue":true
}

sysInfo

ACG: memorymanager.query

Description

Provides a way to account for memory usage.

Parameters

None

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Method execution is successful
  • false: Method executed with errors. Check the errorCode and errorText 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.

System ViewRequiredObject array: system_view

Indicates the system level memory information.

PSS ViewRequiredObject 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

availableRequiredNumber

Indicates the available memory.

totalRequiredNumber

Indicates the total memory.

levelRequiredString

Indicates the current memory status.

Possible values are:

  • normal
  • low
  • critical

application

Indicates the application memory description.

Name

Required

Type

Description

appIdRequiredString

Indicates the application ID.

statusRequiredString

Indicates the status of the application.

Possible values are:

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

Indicates the process ID.

timeRequiredNumber

Indicates the timestamp about 'foreground' apps.

typeRequiredString

Indicates the application type.

Possible values are:

  • web
  • native
  • qml
  • unknown

threshold

Indicates the memory level threshold.

Name

Required

Type

Description

lowRequiredObject: threshold_item

Indicates the low threshold.

criticalRequiredObject: threshold_item

Indicates the critical threshold.

threshold_item

Indicates the threshold item.

Name

Required

Type

Description

enterRequiredNumber

Indicates the enter threshold.

exitRequiredNumber

Indicates the exit threshold.

system_view

Provides system-level memory information.

Name

Required

Type

Description

EssentialRequiredString array

Indicates the essential memory to run the system.

Values are:

  • BSP
  • Kernel
  • Custom Kernel
  • System PSS
ForegroundRequiredString array

Indicates the memory of processes that interacts with users.

Value is:

  • Foreground PSS
FreeRequiredString array

Indicates the free memory.

Value is:

  • Free
PerformanceRequiredString array

Indicates the memory that does not interact with users, but memory for performance improvement.

Values are:

  • Cached Kernel
  • Cached PSS

pss_view

PSS information of services and applications per session

Name

Required

Type

Description

hostRequiredObject array

Indicates the PSS information on host session.

driver0OptionalObject array

Indicates the PSS information on driver0 session.

guest0OptionalObject array

Indicates the PSS information on guest0 session.

guest1OptionalObject 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

previousRequiredObject array

Indicates the previous memory level.

currentRequiredObject array

Indicates the current memory level.

API Error Codes Reference

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

Contents