diff --git a/OOMAnalyser.html b/OOMAnalyser.html
index c115f12..35cb149 100644
--- a/OOMAnalyser.html
+++ b/OOMAnalyser.html
@@ -934,6 +934,7 @@ window.onerror = function (msg, url, lineNo, columnNo, errorObj) {
General
+ - Fix memory calculation in summary section
- ...
diff --git a/OOMAnalyser.py b/OOMAnalyser.py
index 5cb53d6..dda6729 100644
--- a/OOMAnalyser.py
+++ b/OOMAnalyser.py
@@ -1196,22 +1196,23 @@ class OOMAnalyser:
self.oom_result.details['swap_used_kb'] = self.oom_result.details['swap_total_kb'] - self.oom_result.details['swap_free_kb'] - \
self.oom_result.details['swap_cache_kb']
self.oom_result.details['system_swap_used_percent'] = int(100 *
- self.oom_result.details['swap_total_kb'] /
- self.oom_result.details['swap_used_kb'])
+ self.oom_result.details['swap_used_kb'] /
+ self.oom_result.details['swap_total_kb'])
def _calc_system_values(self):
"""Calculate system memory"""
- # educated guess
- self.oom_result.details['page_size_kb'] = 4
-
# calculate remaining explanation values
- self.oom_result.details['system_total_ram_kb'] = self.oom_result.details['ram_pages'] * self.oom_result.details['page_size_kb']
+ self.oom_result.details['system_total_ram_kb'] = self.oom_result.details['ram_pages'] * \
+ self.oom_result.details['page_size_kb']
if self.oom_result.swap_active:
self.oom_result.details['system_total_ramswap_kb'] = self.oom_result.details['system_total_ram_kb'] + \
self.oom_result.details['swap_total_kb']
else:
self.oom_result.details['system_total_ramswap_kb'] = self.oom_result.details['system_total_ram_kb']
+
+ # TODO: Used RSS calculation based on process table is probably incorrect, because it don't differentiates
+ # between processes and threads
total_rss_pages = 0
for pid in self.oom_result.details['_pstable'].keys():
total_rss_pages += self.oom_result.details['_pstable'][pid]['rss_pages']
@@ -1244,6 +1245,9 @@ class OOMAnalyser:
dist = 'Ubuntu'
self.oom_result.details['dist'] = dist
+ # educated guess
+ self.oom_result.details['page_size_kb'] = 4
+
def _calc_from_oom_details(self):
"""
Calculate values from already extracted details
@@ -1255,10 +1259,10 @@ class OOMAnalyser:
self._calc_pstable_values()
self._determinate_platform_and_distribution()
+ self._calc_swap_values()
self._calc_system_values()
self._calc_trigger_process_values()
self._calc_killed_process_values()
- self._calc_swap_values()
def analyse(self):
"""
diff --git a/test.py b/test.py
index 4b54df1..1836655 100755
--- a/test.py
+++ b/test.py
@@ -189,6 +189,16 @@ class TestInBrowser(TestBase):
self.assertTrue('OOM killer was automatically triggered' in explanation.text,
'Missing text "OOM killer was automatically triggered"')
+ explanation = self.driver.find_element(By.ID, 'explanation')
+ self.assertTrue("system has 33519336 kBytes physical memory and 8388604 kBytes swap space." in explanation.text,
+ "Physical and swap memory in summary not found")
+ self.assertTrue("That's 41907940 kBytes total." in explanation.text,
+ "Total memory in summary not found")
+ self.assertTrue("94% (31705788 kBytes out of 33519336 kBytes) physical memory" in explanation.text,
+ "Used physical memory in summary not found")
+ self.assertTrue("99% (8343236 kBytes out of 8388604 kBytes) swap space" in explanation.text,
+ "Used swap space in summary not found")
+
head = self.driver.find_element(By.ID, 'pstable_header')
self.assertTrue('Page Table Entries' in head.text, 'Missing column head line "Page Table Entries"')
@@ -209,6 +219,12 @@ class TestInBrowser(TestBase):
self.assertFalse('with an OOM score of' in explanation.text,
'No OOM score but text "with an OOM score of"')
+ explanation = self.driver.find_element(By.ID, 'explanation')
+ self.assertTrue("system has 2096632 kBytes physical memory and no swap space" in explanation.text,
+ "Physical and swap memory in summary not found")
+ self.assertTrue("9% (209520 kBytes out of 2096632 kBytes) physical memory" in explanation.text,
+ "Used physical memory in summary not found")
+
head = self.driver.find_element(By.ID, 'pstable_header')
self.assertTrue('Page Table Bytes' in head.text, 'Missing column head line "Page Table Bytes"')