traceroute: fix help text to not show -6 when traceroute6 is off
[oweals/busybox.git] / libbb / appletlib.c
index 814b8bcd22d62742fe625cb1164de30248960911..b31532a931be0120b280f2a1192330161387cfd1 100644 (file)
  * FEATURE_INSTALLER or FEATURE_SUID will still link printf routines in. :(
  */
 
-#include <assert.h>
 #include "busybox.h"
+#include <assert.h>
+#include <malloc.h>
+#include <sys/user.h> /* PAGE_SIZE */
 
 
 /* Declare <applet>_main() */
@@ -763,6 +765,24 @@ int lbb_main(char **argv)
 int main(int argc UNUSED_PARAM, char **argv)
 #endif
 {
+       /* Tweak malloc for reduced memory consumption */
+#ifndef PAGE_SIZE
+# define PAGE_SIZE (4*1024) /* guess */
+#endif
+#ifdef M_TRIM_THRESHOLD
+       /* M_TRIM_THRESHOLD is the maximum amount of freed top-most memory
+        * to keep before releasing to the OS
+        * Default is way too big: 256k
+        */
+       mallopt(M_TRIM_THRESHOLD, 2 * PAGE_SIZE);
+#endif
+#ifdef M_MMAP_THRESHOLD
+       /* M_MMAP_THRESHOLD is the request size threshold for using mmap()
+        * Default is too big: 256k
+        */
+       mallopt(M_MMAP_THRESHOLD, 8 * PAGE_SIZE - 256);
+#endif
+
 #if defined(SINGLE_APPLET_MAIN)
        /* Only one applet is selected by the user! */
        /* applet_names in this case is just "applet\0\0" */