Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
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
198592a0
Commit
198592a0
authored
9 years ago
by
Michael McConville
Browse files
Options
Download
Email Patches
Plain Diff
Plug mem leak, improve CPU enumeration logic
I think this leak may still exist in the FreeBSD port.
parent
be9edc5d
master
fixedgray
linear-graph-scan
lua
next
perfcounters
pkgconfig-on-linux
solaris
3.0.0beta5
3.0.0beta4
3.0.0beta3
3.0.0beta2
3.0.0beta1
2.2.0
2.1.0
2.0.2
2.0.1
2.0.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbsd/OpenBSDProcessList.c
+8
-4
openbsd/OpenBSDProcessList.c
with
8 additions
and
4 deletions
+8
-4
openbsd/OpenBSDProcessList.c
View file @
198592a0
...
...
@@ -48,19 +48,21 @@ static long fscale;
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
)
{
int
mib
[]
=
{
CTL_HW
,
HW_NCPU
};
int
fmib
[]
=
{
CTL_KERN
,
KERN_FSCALE
};
int
i
;
int
i
,
e
;
OpenBSDProcessList
*
fpl
=
calloc
(
1
,
sizeof
(
OpenBSDProcessList
));
ProcessList
*
pl
=
(
ProcessList
*
)
fpl
;
size_t
size
=
sizeof
(
pl
->
cpuCount
);
ProcessList_init
(
pl
,
Class
(
OpenBSDProcess
),
usersTable
,
pidWhiteList
,
userId
);
pl
->
cpuCount
=
1
;
// default to 1 on sysctl() error
(
void
)
sysctl
(
mib
,
2
,
&
pl
->
cpuCount
,
&
size
,
NULL
,
0
);
e
=
sysctl
(
mib
,
2
,
&
pl
->
cpuCount
,
&
size
,
NULL
,
0
);
if
(
e
==
-
1
||
pl
->
cpuCount
<
1
)
{
pl
->
cpuCount
=
1
;
}
fpl
->
cpus
=
realloc
(
fpl
->
cpus
,
pl
->
cpuCount
*
sizeof
(
CPUData
));
size
=
sizeof
(
fscale
);
if
(
sysctl
(
fmib
,
2
,
&
fscale
,
&
size
,
NULL
,
0
)
<
0
)
err
(
1
,
"fscale sysctl call failed"
);
err
(
1
,
"fscale sysctl call failed"
);
for
(
i
=
0
;
i
<
pl
->
cpuCount
;
i
++
)
{
fpl
->
cpus
[
i
].
totalTime
=
1
;
...
...
@@ -80,6 +82,8 @@ void ProcessList_delete(ProcessList* this) {
const
OpenBSDProcessList
*
fpl
=
(
OpenBSDProcessList
*
)
this
;
if
(
fpl
->
kd
)
kvm_close
(
fpl
->
kd
);
free
(
fpl
->
cpus
);
ProcessList_done
(
this
);
free
(
this
);
}
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help