Skip to content

Commit f678e22

Browse files
textanalyticsmantextanalyticsman
textanalyticsman
authored and
textanalyticsman
committed
Adding comments for intructor
1 parent 8f46ccd commit f678e22

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/linux_parser.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,21 @@ std::string LinuxParser::RegularExpression(std::string patttern, std::string tex
8686
return result;
8787
}
8888

89-
// I need to get the first value from MemTotal: 33263352 kB
90-
// Then I need the second value from MemFree: 23736848 kB
91-
// Last I have to execute (MemTotal-MemFree)/100 to get the ratio
92-
// When it comes to memory the file always starts MemTotal and then MemFree
89+
/*
90+
I need to get the first value from MemTotal: 33263352 kB
91+
Then I need the second value from MemFree: 23736848 kB
92+
Last I have to execute (MemTotal-MemFree)/100 to get the ratio
93+
When it comes to memory the file always starts MemTotal and then MemFree
94+
On WSL /proc/meminfo returns
95+
MemTotal: 33263352 kB
96+
MemFree: 22359900 kB
97+
However, on Ubuntu without WSL it returns
98+
MemTotal: 3825964 kB
99+
MemFree: 1262180 kB
100+
MemAvailable: 2518760 kB
101+
Thus the regular expression has been modified to get just MemTotal and MemFree
102+
*/
103+
93104
float LinuxParser::MemoryUtilization()
94105
{
95106
std::string line;
@@ -98,7 +109,7 @@ float LinuxParser::MemoryUtilization()
98109
std::vector<float> memory_values;
99110

100111
// Pattern to look for memory information inside /proc/meminfo
101-
std::string pattern{ R"((Mem\w*:)(\s)*(\d+)(\s*)(kB)?)" };
112+
std::string pattern{ R"((Mem[^A]\w*:)(\s)*(\d+)(\s*)(kB)?)" };
102113

103114
std::ifstream filestream(kProcDirectory + kMeminfoFilename);
104115
if (filestream.is_open())

0 commit comments

Comments
 (0)