diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-03 17:42:53 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-03 17:42:53 +0200 |
commit | 7f0ebbc69ed14b2f35e8bc62b03612b94e270955 (patch) | |
tree | 42711057a9eb9ea6222eb4107dfc7626df826e58 | |
parent | a769390da604b4815535e296d8a46fdf9094c2c7 (diff) | |
download | busybox-w32-7f0ebbc69ed14b2f35e8bc62b03612b94e270955.tar.gz busybox-w32-7f0ebbc69ed14b2f35e8bc62b03612b94e270955.tar.bz2 busybox-w32-7f0ebbc69ed14b2f35e8bc62b03612b94e270955.zip |
hush: add commented-out debug printouts in "memleak" built-in
Allocation addresses of malloc() are jittery,
thought I had a mem leak in hush, but it was malloc variability.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/appletlib.c | 8 | ||||
-rw-r--r-- | shell/hush.c | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index f760af2cb..2d01a3ae7 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -942,6 +942,14 @@ int main(int argc UNUSED_PARAM, char **argv) | |||
942 | */ | 942 | */ |
943 | mallopt(M_MMAP_THRESHOLD, 32 * 1024 - 256); | 943 | mallopt(M_MMAP_THRESHOLD, 32 * 1024 - 256); |
944 | #endif | 944 | #endif |
945 | #if 0 /*def M_TOP_PAD*/ | ||
946 | /* When the program break is increased, then M_TOP_PAD bytes are added | ||
947 | * to the sbrk(2) request. When the heap is trimmed because of free(3), | ||
948 | * this much free space is preserved at the top of the heap. | ||
949 | * glibc default seems to be way too big: 128k, but need to verify. | ||
950 | */ | ||
951 | mallopt(M_TOP_PAD, 8 * 1024); | ||
952 | #endif | ||
945 | 953 | ||
946 | #if !BB_MMU | 954 | #if !BB_MMU |
947 | /* NOMMU re-exec trick sets high-order bit in first byte of name */ | 955 | /* NOMMU re-exec trick sets high-order bit in first byte of name */ |
diff --git a/shell/hush.c b/shell/hush.c index 668b1f2b7..9b51f389e 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -9284,6 +9284,15 @@ static int FAST_FUNC builtin_memleak(char **argv UNUSED_PARAM) | |||
9284 | if (l < (unsigned long)p) l = (unsigned long)p; | 9284 | if (l < (unsigned long)p) l = (unsigned long)p; |
9285 | free(p); | 9285 | free(p); |
9286 | 9286 | ||
9287 | |||
9288 | # if 0 /* debug */ | ||
9289 | { | ||
9290 | struct mallinfo mi = mallinfo(); | ||
9291 | printf("top alloc:0x%lx malloced:%d+%d=%d\n", l, | ||
9292 | mi.arena, mi.hblkhd, mi.arena + mi.hblkhd); | ||
9293 | } | ||
9294 | # endif | ||
9295 | |||
9287 | if (!G.memleak_value) | 9296 | if (!G.memleak_value) |
9288 | G.memleak_value = l; | 9297 | G.memleak_value = l; |
9289 | 9298 | ||