[git commit master] experimentally add mallopt tweaks for reduced memory consumption
Denys Vlasenko
vda.linux at googlemail.com
Sun Sep 6 00:12:28 UTC 2009
commit: http://git.busybox.net/busybox/commit/?id=1f7c167b23dfd5b03f386a657cb95867e1605e1b
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
mallopt - 126 +126
main 91 117 +26
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 152/0) Total: 152 bytes
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
libbb/appletlib.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 814b8bc..0ebea4f 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -28,6 +28,8 @@
*/
#include <assert.h>
+#include <malloc.h>
+#include <sys/user.h> /* PAGE_SIZE */
#include "busybox.h"
@@ -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" */
--
1.6.3.3
More information about the busybox-cvs
mailing list