The random access memory, RAM, is a type of computer memory that can be accessed randomly. That is, any byte of memory can be accessed without touching the preceding bytes. It is the most common type of memory found in computers, smartphones, and embedded devices.

Digi adds to Android an API to obtain different memory values of the ConnectCore 6 modules. You can get the total, free, cached and available memory values. In the Digi APIx javadoc you can find a complete list of the available methods in this API.

Unless noted, all memory API methods require the permission.

If your application does not have the permission it will not have access to any memory service feature.

In order to obtain the memory values, you need to instantiate a MemoryManager object. To do so, you have to provide the application Context.

Instantiating the MemoryManager
import android.os.Bundle;


public class MemorySampleActivity extends Activity {

    MemoryManager memoryManager;


    public void onCreate(Bundle savedInstanceState) {

        // Instantiate the Memory manager object.
        memoryManager = new MemoryManager(this);



Obtain the memory values

You can read the total, free, cached and available memory values using the following methods:

Method Description


Returns the device’s total usable memory in kB (i.e. physical RAM minus a few reserved bits and the kernel binary code)


Returns the device’s free memory in kB


Returns the device’s in-memory cache for files read from the disk in kB


Returns the device’s available memory in kB. An estimate of how much memory is available for starting new applications, without swapping.

These methods may fail if there is any error while reading the memory values throwing an IOException.

Getting the memory values


MemoryManager memoryManager = ...;


System.out.println("Total memory: " + memoryManager.getTotalMemory() + "kB");
System.out.println("Free memory: " + memoryManager.getFreeMemory() + "kB");
System.out.println("Cached memory: " + memoryManager.getCachedMemory() + "kB");
System.out.println("Available memory: " + memoryManager.getAvailableMemory() + "kB");


Memory example

Example: Memory

This API does not have a separate example. Instead, it is integrated in the CPU Management Sample Application, which demonstrates the usage of the CPU and memory APIs.

You can import the example using Digi’s Android Studio plugin. For more information, see Import a Digi sample application. To look at the application source code, go to the GitHub repository.