Merge pull request #104 from jameshanlon/fix-103

Use stol() for determining Linux memory use
This commit is contained in:
Matt McCormick 2024-05-22 12:04:07 -04:00 committed by GitHub
commit 93525a5517
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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