Merge pull request #52 from jmmweismiller/master

Updated used memory calculation.
This commit is contained in:
Matt McCormick 2018-04-13 23:35:56 -04:00 committed by GitHub
commit abe7290511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,7 +40,7 @@ void mem_status( MemoryStatus & status )
* application requests memory. * application requests memory.
* In order to calculate the ram that's actually used we need to use the * In order to calculate the ram that's actually used we need to use the
* following formula: * following formula:
* total_ram - free_ram - buffered_ram - cached_ram * total_ram + shmem - free_ram - buffered_ram - cached_ram - srclaimable
* *
* example data, junk removed, with comments added: * example data, junk removed, with comments added:
* *
@ -72,8 +72,13 @@ void mem_status( MemoryStatus & status )
{ {
used_mem = total_mem - stoi( line.substr( substr_start, substr_len ) ); used_mem = total_mem - stoi( line.substr( substr_start, substr_len ) );
} }
else if( substr.compare( "Shmem" ) == 0 )
{
used_mem += stoi( line.substr( substr_start, substr_len ) );
}
else if( substr.compare( "Buffers" ) == 0 || else if( substr.compare( "Buffers" ) == 0 ||
substr.compare( "Cached" ) == 0 ) substr.compare( "Cached" ) == 0 ||
substr.compare( "SReclaimable" ) == 0 )
{ {
used_mem -= stoi( line.substr( substr_start, substr_len ) ); used_mem -= stoi( line.substr( substr_start, substr_len ) );
} }