Skip to content

Commit

Permalink
Fix parsing of linux proc file. Fixes: #2
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed May 1, 2022
1 parent c2a1dc7 commit b0f426b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.0.3 (2022-04-30)
======
* Fix parsing of proc file on linux.

0.0.2 (2022-04-27)
======
* Fix segfault (#1)
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(lang dune 2.8)
(version 0.0.2)
(version 0.0.3)
(name mem_usage)
(source (github savonet/ocaml-mem_usage))
(license GPL-2.0)
Expand Down
8 changes: 4 additions & 4 deletions lib/mem_usage.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ CAMLprim value ocaml_mem_usage_mem_usage(value unit) {
if (file) {
while (fscanf(file, " %1023s", buffer) == 1) {
if (strcmp(buffer, "VmSize:") == 0) {
if (fscanf(file, " %d", &process_virtual_memory) != 1)
if (fscanf(file, " %lld", &process_virtual_memory) != 1)
process_virtual_memory = 0;
process_virtual_memory *= 1024;
break;
continue;
}

if (strcmp(buffer, "VmRSS:") == 0) {
if (fscanf(file, " %d", &process_physical_memory) != 1)
if (fscanf(file, " %lld", &process_physical_memory) != 1)
process_physical_memory = 0;
process_physical_memory *= 1024;
break;
continue;
}
}
fclose(file);
Expand Down
2 changes: 1 addition & 1 deletion mem_usage.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "0.0.2"
version: "0.0.3"
synopsis: "Cross-platform stats about memory usage"
maintainer: ["The Savonet Team <[email protected]>"]
authors: ["Romain Beauxis <[email protected]>"]
Expand Down

0 comments on commit b0f426b

Please sign in to comment.