Use stol() for determining Linux memory use

To acommodate large memory machines.
This commit is contained in:
James Hanlon 2024-05-22 09:23:58 +01:00
parent bf0b2721df
commit 13160c7e80

@ -66,21 +66,21 @@ void mem_status( MemoryStatus & status )
if( substr.compare( "MemTotal" ) == 0 ) if( substr.compare( "MemTotal" ) == 0 )
{ {
// get total memory // get total memory
total_mem = stoi( line.substr( substr_start, substr_len ) ); total_mem = stol( line.substr( substr_start, substr_len ) );
} }
else if( substr.compare( "MemFree" ) == 0 ) else if( substr.compare( "MemFree" ) == 0 )
{ {
used_mem = total_mem - stoi( line.substr( substr_start, substr_len ) ); used_mem = total_mem - stol( line.substr( substr_start, substr_len ) );
} }
else if( substr.compare( "Shmem" ) == 0 ) else if( substr.compare( "Shmem" ) == 0 )
{ {
used_mem += stoi( line.substr( substr_start, substr_len ) ); used_mem += stol( 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 ) substr.compare( "SReclaimable" ) == 0 )
{ {
used_mem -= stoi( line.substr( substr_start, substr_len ) ); used_mem -= stol( line.substr( substr_start, substr_len ) );
} }
} }