Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heap usage: int and time_t are used instead of size_t by mistake #34

Open
kapvode opened this issue Nov 14, 2017 · 1 comment
Open

Heap usage: int and time_t are used instead of size_t by mistake #34

kapvode opened this issue Nov 14, 2017 · 1 comment

Comments

@kapvode
Copy link

kapvode commented Nov 14, 2017

I get the following reason in a leak event.

heap growth over 5 consecutive GCs (56s) - -2147483648 bytes/hr

With the included patch, it looks better.

heap growth over 5 consecutive GCs (1m 4s) - 2430.35 mb/hr

This is about a minute after the application starts. The growth was 45305024 bytes, so that's the reason for the high growth rate that is reported.

@kapvode
Copy link
Author

kapvode commented Nov 14, 2017

diff --git a/src/memwatch.cc b/src/memwatch.cc
index 6ebed41..186887d 100644
--- a/src/memwatch.cc
+++ b/src/memwatch.cc
@@ -60,7 +60,7 @@ static struct
     // the period from which this leak analysis starts
     time_t leak_time_start;
     // the base memory for the detection period
-    time_t leak_base_start;
+    size_t leak_base_start;
     // the number of consecutive compactions for which we've grown
     unsigned int consecutive_growth;
 } s_stats;
diff --git a/src/util.cc b/src/util.cc
index 81fcd88..b41a198 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -10,7 +10,7 @@
 #include <stdlib.h> // abs()

 std::string
-mw_util::niceSize(int bytes) 
+mw_util::niceSize(size_t bytes)
 {
     std::stringstream ss;

diff --git a/src/util.hh b/src/util.hh
index c7a967b..987f303 100644
--- a/src/util.hh
+++ b/src/util.hh
@@ -7,7 +7,7 @@
 namespace mw_util {
     // given a size in bytes, return a human readable representation of the
     // string
-    std::string niceSize(int bytes);
+    std::string niceSize(size_t bytes);

     // given a delta in seconds, return a human redable representation
     std::string niceDelta(int seconds);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant