test/exclude line starting with MemAvailable
tested for line starting w/ 'MemAvailable' and exclude from used memory calculation by simply decrementing the index variable by 1 and proceeding
This commit is contained in:
parent
4c9c9dde85
commit
b12dfc6f29
@ -267,6 +267,14 @@ std::string mem_string( bool use_colors )
|
|||||||
for( unsigned int i = 0; i < 3; i++ )
|
for( unsigned int i = 0; i < 3; i++ )
|
||||||
{
|
{
|
||||||
getline( meminfo_file, mem_line );
|
getline( meminfo_file, mem_line );
|
||||||
|
// accomodate MemAvailable potentially being in lines 2-4 of /proc/meminfo
|
||||||
|
// did this in a way to not break the original logic of the loop
|
||||||
|
if( mem_line.find("MemAvailable") == 0 )
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
line_start_pos = mem_line.find_first_of( ':' );
|
line_start_pos = mem_line.find_first_of( ':' );
|
||||||
line_start_pos++;
|
line_start_pos++;
|
||||||
line_end_pos = mem_line.find_first_of( 'k' );
|
line_end_pos = mem_line.find_first_of( 'k' );
|
||||||
@ -274,6 +282,7 @@ std::string mem_string( bool use_colors )
|
|||||||
iss >> unused_mem;
|
iss >> unused_mem;
|
||||||
used_mem -= unused_mem;
|
used_mem -= unused_mem;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
meminfo_file.close();
|
meminfo_file.close();
|
||||||
|
|
||||||
#endif // platform
|
#endif // platform
|
||||||
|
Loading…
Reference in New Issue
Block a user