Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Memory saving ideas, Getting rid of bash instances< Next Oldest | Next Newest >
alih Offline





Group: Members
Posts: 1
Joined: May 2008
Posted: May 23 2008,22:20 QUOTE

Hi,

(typing this from a P266/32M machine)
Here's my experience with memory saving. Apart from the obvious turning off the background and the icons I came to think that bash eats too much memory. At a normal run of X, there are 3 bashes:
1) root's login shell;
2) user's login shell;
3) interpreter of startx.

I've dealed with them all to get bash-free memory. Here's how I did it.

1) I haven't found any better than append this to /etc/profile:
Code Sample

if [ x"/bin/bash" = x"$0" -a "$(whoami)" = "root" ]; then
    exec su - dsl
fi

This gives up root login shell. It will probably be bad for single-user mode but I don't care.

2) Added this to /home/dsl/.bash_profile:
alias startx="exec startx"
When you quit X, bash will be respawned by init. It works exactly as if bash was alive all this time except returning to the home directory.

3) Edited /usr/X11R6/bin/startx: changed the interpreter to /bin/ash and a couple of constructs looking like
Code Sample
if ! X; then Y fi
to
Code Sample
if X; then :; else Y fi
.

Now when I start X torsmo shows 4.7M of taken memory (your mileage may vary since I have things like cardmgr). Together with kernel memory, it's about 8M of 32. So 32M isn't not that small after all :)

Hope that might help somebody.
Back to top
Profile PM 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: May 24 2008,08:05 QUOTE

Nice :)

To further save on resources, use $UID="0" instead of $(whoami)="root", since starting an app is way heavier than reading an environment variable.

Also you might want to compile your own kernel for that machine, it's a good way to spare some ram too.

Edit: Actually, why even put that into /etc/profile? Root's bashrc already does that (in runlevel 5 and without exec though), so it's kinda just duplicating effort


--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: May 29 2008,10:41 QUOTE

Quote
Code Sample if ! X; then Y fi
to
Code Sample if X; then :; else Y fi


Wondering why that should save memory?  X gets executed either way?
Back to top
Profile PM 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: May 29 2008,14:36 QUOTE

That wasn't for saving memory, it was because ash doesn't understand the bash-y syntax if ! X..

--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
3 replies since May 23 2008,22:20 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Memory saving ideas

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code