Skip to content

Commit

Permalink
Fix process memory
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamVenner committed Jul 15, 2021
1 parent 409bdd1 commit c31f1d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ macro_rules! system {
$code
})
};

(mut $sys:ident, $code:expr) => {
SYSTEM.with(|sys| {
let mut $sys = sys.borrow_mut();
Expand All @@ -35,7 +35,7 @@ macro_rules! system {
$code
})
};

($sys:ident, $code:expr) => {
SYSTEM.with(|sys| {
let $sys = sys.borrow_mut();
Expand Down Expand Up @@ -136,15 +136,15 @@ pub unsafe extern "C-unwind" fn process_cpu_usage(lua: lua::State) -> i32 {
}
*cpu_usage
}));

1
}

pub unsafe extern "C-unwind" fn process_memory_usage(lua: lua::State) -> i32 {
system!(mut sys, {
sys.refresh_memory();
let process = process!(sys);
lua.push_number((process.memory() + process.virtual_memory()) as f64 / 1024.);
lua.push_number(process.memory() as f64 / 1024.);
});
1
}
Expand Down

0 comments on commit c31f1d3

Please sign in to comment.