ProcessController: Fix memory calculations.
On systems with > 4GB of memory, the calculations would overflow, leading to the memory bars being drawn incorrectly.
This commit is contained in:
@@ -39,9 +39,9 @@ KernelMemoryBarMenuItem::KernelMemoryBarMenuItem(system_info& systemInfo)
|
|||||||
fLastSum = -1;
|
fLastSum = -1;
|
||||||
fGrenze1 = -1;
|
fGrenze1 = -1;
|
||||||
fGrenze2 = -1;
|
fGrenze2 = -1;
|
||||||
fPhysicalMemory = systemInfo.max_pages * B_PAGE_SIZE / 1024LL;
|
fPhysicalMemory = (int64)systemInfo.max_pages * B_PAGE_SIZE / 1024LL;
|
||||||
fCommittedMemory = systemInfo.used_pages * B_PAGE_SIZE / 1024LL;
|
fCommittedMemory = (int64)systemInfo.used_pages * B_PAGE_SIZE / 1024LL;
|
||||||
fCachedMemory = systemInfo.cached_pages * B_PAGE_SIZE / 1024LL;
|
fCachedMemory = (int64)systemInfo.cached_pages * B_PAGE_SIZE / 1024LL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ MemoryBarMenu::Pulse()
|
|||||||
{
|
{
|
||||||
system_info sinfo;
|
system_info sinfo;
|
||||||
get_system_info(&sinfo);
|
get_system_info(&sinfo);
|
||||||
int committedMemory = int(sinfo.used_pages * B_PAGE_SIZE / 1024);
|
int64 committedMemory = (int64)sinfo.used_pages * B_PAGE_SIZE / 1024;
|
||||||
int cachedMemory = int(sinfo.cached_pages * B_PAGE_SIZE / 1024);
|
int64 cachedMemory = (int64)sinfo.cached_pages * B_PAGE_SIZE / 1024;
|
||||||
Window()->BeginViewTransaction();
|
Window()->BeginViewTransaction();
|
||||||
|
|
||||||
// create the list of items to remove, for their team is gone. Update the old teams.
|
// create the list of items to remove, for their team is gone. Update the old teams.
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ MemoryBarMenuItem::Init()
|
|||||||
fAllMemory = -1;
|
fAllMemory = -1;
|
||||||
fGrenze1 = -1;
|
fGrenze1 = -1;
|
||||||
fGrenze2 = -1;
|
fGrenze2 = -1;
|
||||||
fLastCommited = -1;
|
fLastCommitted = -1;
|
||||||
fLastWrite = -1;
|
fLastWrite = -1;
|
||||||
fLastAll = -1;
|
fLastAll = -1;
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ MemoryBarMenuItem::DrawBar(bool force)
|
|||||||
{
|
{
|
||||||
// only draw anything if something has changed
|
// only draw anything if something has changed
|
||||||
if (!force && fWriteMemory == fLastWrite && fAllMemory == fLastAll
|
if (!force && fWriteMemory == fLastWrite && fAllMemory == fLastAll
|
||||||
&& fCommitedMemory == fLastCommited)
|
&& fCommittedMemory == fLastCommitted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool selected = IsSelected();
|
bool selected = IsSelected();
|
||||||
@@ -135,8 +135,10 @@ MemoryBarMenuItem::DrawBar(bool force)
|
|||||||
|
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
BRect r = rect;
|
BRect r = rect;
|
||||||
double grenze1 = rect.left + (rect.right - rect.left) * float(fWriteMemory) / fCommitedMemory;
|
double grenze1 = rect.left + (rect.right - rect.left) * float(fWriteMemory)
|
||||||
double grenze2 = rect.left + (rect.right - rect.left) * float(fAllMemory) / fCommitedMemory;
|
/ fCommittedMemory;
|
||||||
|
double grenze2 = rect.left + (rect.right - rect.left) * float(fAllMemory)
|
||||||
|
/ fCommittedMemory;
|
||||||
if (grenze1 > rect.right)
|
if (grenze1 > rect.right)
|
||||||
grenze1 = rect.right;
|
grenze1 = rect.right;
|
||||||
if (grenze2 > rect.right)
|
if (grenze2 > rect.right)
|
||||||
@@ -188,7 +190,7 @@ MemoryBarMenuItem::DrawBar(bool force)
|
|||||||
fGrenze1 = grenze1;
|
fGrenze1 = grenze1;
|
||||||
fGrenze2 = grenze2;
|
fGrenze2 = grenze2;
|
||||||
|
|
||||||
fLastCommited = fCommitedMemory;
|
fLastCommitted = fCommittedMemory;
|
||||||
|
|
||||||
// Draw the values if necessary; if only fCommitedMemory changes, only
|
// Draw the values if necessary; if only fCommitedMemory changes, only
|
||||||
// the bar might have to be updated
|
// the bar might have to be updated
|
||||||
@@ -234,9 +236,9 @@ MemoryBarMenuItem::GetContentSize(float* _width, float* _height)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
MemoryBarMenuItem::UpdateSituation(int64 commitedMemory)
|
MemoryBarMenuItem::UpdateSituation(int64 committedMemory)
|
||||||
{
|
{
|
||||||
fCommitedMemory = commitedMemory;
|
fCommittedMemory = committedMemory;
|
||||||
BarUpdate();
|
BarUpdate();
|
||||||
return fWriteMemory;
|
return fWriteMemory;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,17 +36,17 @@ class MemoryBarMenuItem : public BMenuItem {
|
|||||||
|
|
||||||
void DrawIcon();
|
void DrawIcon();
|
||||||
void DrawBar(bool force);
|
void DrawBar(bool force);
|
||||||
int UpdateSituation(int64 commitedMemory);
|
int UpdateSituation(int64 committedMemory);
|
||||||
void BarUpdate();
|
void BarUpdate();
|
||||||
void Init();
|
void Init();
|
||||||
void Reset(char* name, team_id team, BBitmap* icon, bool deleteIcon);
|
void Reset(char* name, team_id team, BBitmap* icon, bool deleteIcon);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int64 fPhysicalMemory;
|
int64 fPhysicalMemory;
|
||||||
int64 fCommitedMemory;
|
int64 fCommittedMemory;
|
||||||
int64 fWriteMemory;
|
int64 fWriteMemory;
|
||||||
int64 fAllMemory;
|
int64 fAllMemory;
|
||||||
int64 fLastCommited;
|
int64 fLastCommitted;
|
||||||
int64 fLastWrite;
|
int64 fLastWrite;
|
||||||
int64 fLastAll;
|
int64 fLastAll;
|
||||||
team_id fTeamID;
|
team_id fTeamID;
|
||||||
|
|||||||
@@ -738,14 +738,14 @@ thread_popup(void *arg)
|
|||||||
// Memory Usage section
|
// Memory Usage section
|
||||||
MemoryBarMenu* MemoryPopup = new MemoryBarMenu(B_TRANSLATE("Memory usage"),
|
MemoryBarMenu* MemoryPopup = new MemoryBarMenu(B_TRANSLATE("Memory usage"),
|
||||||
infos, systemInfo);
|
infos, systemInfo);
|
||||||
int commitedMemory = int(systemInfo.used_pages * B_PAGE_SIZE / 1024);
|
int64 committedMemory = (int64)systemInfo.used_pages * B_PAGE_SIZE / 1024;
|
||||||
for (m = 0; m < systemInfo.used_teams; m++) {
|
for (m = 0; m < systemInfo.used_teams; m++) {
|
||||||
if (infos[m].team_info.team >= 0) {
|
if (infos[m].team_info.team >= 0) {
|
||||||
MemoryBarMenuItem* memoryItem =
|
MemoryBarMenuItem* memoryItem =
|
||||||
new MemoryBarMenuItem(infos[m].team_name,
|
new MemoryBarMenuItem(infos[m].team_name,
|
||||||
infos[m].team_info.team, infos[m].team_icon, false, NULL);
|
infos[m].team_info.team, infos[m].team_icon, false, NULL);
|
||||||
MemoryPopup->AddItem(memoryItem);
|
MemoryPopup->AddItem(memoryItem);
|
||||||
memoryItem->UpdateSituation(commitedMemory);
|
memoryItem->UpdateSituation(committedMemory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user