{
FILE *meminfo_fp;
char buf[256];
- unsigned long swap_total, swap_free, value;
+ unsigned long swap_total, swap_free, value, mem_available;
if (info == NULL) {
_E("INVALID_PARAMETER(0x%08x) : invalid output param",
return RUNTIME_INFO_ERROR_INVALID_PARAMETER;
}
- swap_total = swap_free = 0;
+ swap_total = swap_free = mem_available = 0;
meminfo_fp = fopen("/proc/meminfo", "r");
if (meminfo_fp == NULL) {
info->free = kBtoKiB(value);
else if (sscanf(buf, "Cached: %lu", &value) == 1)
info->cache = kBtoKiB(value);
+ else if (sscanf(buf, "MemAvailable: %lu", &value) == 1)
+ mem_available = kBtoKiB(value);
else if (sscanf(buf, "SwapTotal: %lu", &value) == 1)
swap_total = value;
else if (sscanf(buf, "SwapFree: %lu", &value) == 1)
}
fclose(meminfo_fp);
- info->used = (info->total > info->free) ? (info->total - info->free) : 0;
+ info->used = mem_available ? (info->total - mem_available) : (info->total - info->free - info->cache);
info->swap = kBtoKiB(((swap_total > swap_free) ? (int)(swap_total - swap_free) : 0));
return RUNTIME_INFO_ERROR_NONE;