aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-06 02:12:28 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-06 02:12:28 +0200
commit1f7c167b23dfd5b03f386a657cb95867e1605e1b (patch)
tree10f74bc529ecf41d5f93aa1395f179037bbaab91 /libbb/appletlib.c
parent6db4784d27be020d892f92db0cba70452b1c128e (diff)
downloadbusybox-w32-1f7c167b23dfd5b03f386a657cb95867e1605e1b.tar.gz
busybox-w32-1f7c167b23dfd5b03f386a657cb95867e1605e1b.tar.bz2
busybox-w32-1f7c167b23dfd5b03f386a657cb95867e1605e1b.zip
experimentally add mallopt tweaks for reduced memory consumption
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@googlemail.com>
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r--libbb/appletlib.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 814b8bcd2..0ebea4f44 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -28,6 +28,8 @@
28 */ 28 */
29 29
30#include <assert.h> 30#include <assert.h>
31#include <malloc.h>
32#include <sys/user.h> /* PAGE_SIZE */
31#include "busybox.h" 33#include "busybox.h"
32 34
33 35
@@ -763,6 +765,24 @@ int lbb_main(char **argv)
763int main(int argc UNUSED_PARAM, char **argv) 765int main(int argc UNUSED_PARAM, char **argv)
764#endif 766#endif
765{ 767{
768 /* Tweak malloc for reduced memory consumption */
769#ifndef PAGE_SIZE
770# define PAGE_SIZE (4*1024) /* guess */
771#endif
772#ifdef M_TRIM_THRESHOLD
773 /* M_TRIM_THRESHOLD is the maximum amount of freed top-most memory
774 * to keep before releasing to the OS
775 * Default is way too big: 256k
776 */
777 mallopt(M_TRIM_THRESHOLD, 2 * PAGE_SIZE);
778#endif
779#ifdef M_MMAP_THRESHOLD
780 /* M_MMAP_THRESHOLD is the request size threshold for using mmap()
781 * Default is too big: 256k
782 */
783 mallopt(M_MMAP_THRESHOLD, 8 * PAGE_SIZE - 256);
784#endif
785
766#if defined(SINGLE_APPLET_MAIN) 786#if defined(SINGLE_APPLET_MAIN)
767 /* Only one applet is selected by the user! */ 787 /* Only one applet is selected by the user! */
768 /* applet_names in this case is just "applet\0\0" */ 788 /* applet_names in this case is just "applet\0\0" */