Lines 15-21
Link Here
|
15 |
|
15 |
|
16 |
if (sysctlbyname (name, &buf, &len, NULL, 0) < 0) |
16 |
if (sysctlbyname (name, &buf, &len, NULL, 0) < 0) |
17 |
return 0; |
17 |
return 0; |
18 |
@@ -41,13 +41,13 @@ get_mem_by_bytes (const gchar *name) |
18 |
@@ -41,24 +41,25 @@ |
19 |
guint64 |
19 |
guint64 |
20 |
get_mem_by_pages (const gchar *name) |
20 |
get_mem_by_pages (const gchar *name) |
21 |
{ |
21 |
{ |
Lines 24-30
Link Here
|
24 |
|
24 |
|
25 |
res = get_mem_by_bytes (name); |
25 |
res = get_mem_by_bytes (name); |
26 |
if (res > 0) |
26 |
if (res > 0) |
27 |
res = res * getpagesize (); |
27 |
- res = res * getpagesize (); |
|
|
28 |
+ res *= getpagesize (); |
28 |
|
29 |
|
29 |
- return (guint64) res; |
30 |
- return (guint64) res; |
30 |
+ return res; |
31 |
+ return res; |
Lines 31-46
Link Here
|
31 |
} |
32 |
} |
32 |
|
33 |
|
33 |
gboolean |
34 |
gboolean |
34 |
@@ -55,10 +55,10 @@ get_memory_usage (guint64 *memory_total, |
35 |
get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64 *memory_cache, guint64 *memory_buffers, guint64 *swap_total, guint64 *swap_free) |
35 |
{ |
36 |
{ |
36 |
/* Get memory usage */ |
37 |
/* Get memory usage */ |
|
|
38 |
+ /* https://wiki.freebsd.org/Memory */ |
37 |
{ |
39 |
{ |
38 |
- *memory_total = (guint64) get_mem_by_bytes ("hw.physmem");; |
40 |
- *memory_total = (guint64) get_mem_by_bytes ("hw.physmem");; |
39 |
+ *memory_total = get_mem_by_bytes ("hw.physmem");; |
41 |
+ *memory_total = get_mem_by_bytes ("hw.physmem");; |
40 |
*memory_free = get_mem_by_pages ("vm.stats.vm.v_free_count"); |
42 |
*memory_free = get_mem_by_pages ("vm.stats.vm.v_free_count"); |
41 |
*memory_cache = get_mem_by_pages ("vm.stats.vm.v_inactive_count"); |
43 |
- *memory_cache = get_mem_by_pages ("vm.stats.vm.v_inactive_count"); |
42 |
- *memory_buffers = (guint64) get_mem_by_bytes ("vfs.bufspace"); |
44 |
- *memory_buffers = (guint64) get_mem_by_bytes ("vfs.bufspace"); |
43 |
+ *memory_buffers = get_mem_by_bytes ("vfs.bufspace"); |
45 |
+ *memory_cache = 0; // get_mem_by_pages ("vm.stats.vm.v_inactive_count"); |
|
|
46 |
+ *memory_buffers = 0; // Only usable by the kernel // get_mem_by_bytes ("vfs.bufspace"); |
44 |
} |
47 |
} |
45 |
|
48 |
|
46 |
/* Get swap usage */ |
49 |
/* Get swap usage */ |
|
|
50 |
@@ -70,8 +71,8 @@ |
51 |
return FALSE; |
52 |
|
53 |
kvm_getswapinfo (kd, &kswap, 1, 0); |
54 |
- *swap_total = kswap.ksw_total * getpagesize (); |
55 |
- *swap_free = (kswap.ksw_total - kswap.ksw_used) * getpagesize (); |
56 |
+ *swap_total = ((guint64)kswap.ksw_total) * getpagesize (); |
57 |
+ *swap_free = ((guint64)(kswap.ksw_total - kswap.ksw_used)) * getpagesize (); |
58 |
|
59 |
kvm_close (kd); |
60 |
} |