Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
a84aa2e7
Commit
a84aa2e7
authored
Nov 29, 2015
by
Hisham Muhammad
Browse files
Cached memory calculations, take 2.
Thanks to @OmegaPhil for discussion and reviewing.
parent
5bc1f5ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
linux/LinuxProcessList.c
View file @
a84aa2e7
...
...
@@ -621,7 +621,6 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
static
inline
void
LinuxProcessList_scanMemoryInfo
(
ProcessList
*
this
)
{
unsigned
long
long
int
swapFree
=
0
;
unsigned
long
long
int
slab
=
0
;
unsigned
long
long
int
shmem
=
0
;
unsigned
long
long
int
sreclaimable
=
0
;
...
...
@@ -651,9 +650,6 @@ static inline void LinuxProcessList_scanMemoryInfo(ProcessList* this) {
if
(
tryRead
(
"SwapTotal:"
,
&
this
->
totalSwap
))
{}
else
if
(
tryRead
(
"SwapFree:"
,
&
swapFree
))
{}
break
;
case
'l'
:
if
(
tryRead
(
"Slab:"
,
&
slab
))
{}
break
;
case
'h'
:
if
(
tryRead
(
"Shmem:"
,
&
shmem
))
{}
break
;
...
...
@@ -666,8 +662,8 @@ static inline void LinuxProcessList_scanMemoryInfo(ProcessList* this) {
#undef tryRead
}
this
->
usedMem
=
this
->
totalMem
-
this
->
freeMem
+
(
slab
-
sreclaimable
)
+
shmem
;
this
->
cachedMem
=
this
->
cachedMem
+
sreclaimable
;
this
->
usedMem
=
this
->
totalMem
-
this
->
freeMem
;
this
->
cachedMem
=
this
->
cachedMem
+
sreclaimable
-
shmem
;
this
->
usedSwap
=
this
->
totalSwap
-
swapFree
;
fclose
(
file
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment