Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loom
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tom Vander Aa
loom
Commits
40cc6894
There was a problem fetching the pipeline summary.
Commit
40cc6894
authored
7 years ago
by
Vojtech Cima
Browse files
Options
Downloads
Patches
Plain Diff
ENH: get actual RAM usage on macos
parent
fc8c7401
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libloomw/wtrace.cpp
+32
-2
32 additions, 2 deletions
src/libloomw/wtrace.cpp
with
32 additions
and
2 deletions
src/libloomw/wtrace.cpp
+
32
−
2
View file @
40cc6894
...
...
@@ -4,7 +4,12 @@
#include
<libloom/log.h>
#include
<unistd.h>
#ifndef __APPLE__
#ifdef __APPLE__
#include
<mach/vm_statistics.h>
#include
<mach/mach_types.h>
#include
<mach/mach_init.h>
#include
<mach/mach_host.h>
#else
#include
<sys/sysinfo.h>
#endif
...
...
@@ -33,7 +38,32 @@ double read_cpu_time(long hz)
int
read_mem_usage_percent
()
{
#ifdef __APPLE__
return
50
;
vm_size_t
page_size
;
mach_port_t
mach_port
;
mach_msg_type_number_t
count
;
vm_statistics64_data_t
vm_stats
;
mach_port
=
mach_host_self
();
count
=
sizeof
(
vm_stats
)
/
sizeof
(
natural_t
);
int
usage
;
if
(
KERN_SUCCESS
==
host_page_size
(
mach_port
,
&
page_size
)
&&
KERN_SUCCESS
==
host_statistics64
(
mach_port
,
HOST_VM_INFO
,
(
host_info64_t
)
&
vm_stats
,
&
count
))
{
long
long
free_memory
=
static_cast
<
int64_t
>
(
vm_stats
.
free_count
)
*
static_cast
<
int64_t
>
(
page_size
);
long
long
used_memory
=
(
static_cast
<
int64_t
>
(
vm_stats
.
active_count
)
+
static_cast
<
int64_t
>
(
vm_stats
.
inactive_count
)
+
static_cast
<
int64_t
>
(
vm_stats
.
wire_count
))
*
static_cast
<
int64_t
>
(
page_size
);
double
total
=
static_cast
<
double
>
(
free_memory
+
used_memory
);
usage
=
static_cast
<
int
>
(
used_memory
/
total
*
100
);
}
else
{
base
::
logger
->
warn
(
"Cannot read memory utilizaton"
);
usage
=
-
1
;
}
return
usage
;
#else
struct
sysinfo
mem_info
;
if
(
sysinfo
(
&
mem_info
)
<
0
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment