Reducing memory use with urxvtd and urxvtc

Interesting, but by way of dmenu, I discovered something I wish I had known a long time ago: That there is a daemon available to rxvt-unicode, which will allow you to run multiple terminal instances with a slimmer memory footprint and quicker spawning times.

I have always resented the fact that my terminal-based systems running under X incur a rather hefty price in the way of one instance of urxvt per application, which in turn implies one instance of bash per application. (One of these days I’ll get off my rear end and pick a shell that isn’t quite as hefty, relatively speaking, as bash. Suggestions welcomed. :mrgreen: )

I had been using dmenu in Musca to start applications with urxvt -e (application), and each time I saw options for both urxvtd and urxvtc. A quick skim through some man pages, and now I understand that urxvtd is the daemon, and urxvtc triggers the daemon to spawn a new terminal window.

Which means that instead of four terminal emulators taking up a wide slice of the 16Mb I have in this Pentium, I have one daemon running and four applications hooked into it.

Why bother? Well for me, as I have already implied, the amount of space required is suddenly a fraction, inversely proportional to the number of emulators you originally needed. (That makes almost no sense at all, but suffice to say that when I ran tty-clock, centerim and hnb alongside charm, I used to need four terminals and four instances of bash to run them. Now I need only one daemon, which I suppose suggests it takes up one-quarter of the resources. … :| )

Now that we have settled the why, here’s the how: On an ultralight system or any system that relies on .xsession or .xinitrc (which suggests Openbox, et al.), insert this line to the .xinitrc file.

urxvtd -q -o -f

The q flag spares you the startup notification. The o flag picks the open X display and the f flag forks the daemon and takes it out of your way.

Now, whenever you spawn a terminal window, use urxvtc instead of urxvt, and the running daemon will hand you another terminal prompt.

There is a downside to this (there always is, isn’t there?): If the daemon dies, all the applications hooked to it can suffer the same fate.

For me, running that risk is worth it, for two reasons. First, this machine has so little memory to spare, that the 1 or 2 megabytes I save by eliminating the one-emulator-per-application is significant.

Second, the time it takes to open a new prompt is likewise reduced. I recompiled Musca to link the urxvtc command to the Mod4+t key, and now the daemon sprouts a new prompt in a fraction of the time it used to swap out the memory and start a whole new emulator.

I realize this is hardly news, and it’s hardly interesting to anyone who’s not using terminal applications as a matter of course. I probably wouldn’t even bother using this on my Openbox systems just because I don’t use enough terminal applications on those to warrant setting it up.

On the other hand, if you’re a bottom-feeder like me, you will claim back a sliver of memory and a smidgin of start time by relying on the daemon, instead of one emulator per application. ;)

About these ads

7 Responses to “Reducing memory use with urxvtd and urxvtc”


  1. 1 mulenmar 2009/08/26 at 1:26 AM

    Nice, I hadn’t heard of that trick. :)

    In the “lighter shell than bash” department, you could always compile a minimal bash, or even use dash. ;)

  2. 2 Bryan 2009/08/28 at 12:17 PM

    You could always use zsh, though I’m not sure how that relates to bash in terms of memory usage. It certainly provides me some extremely useful perks (smart auto-completion, correction of incorrectly typed commands, suffix matching, AWESOME globbing abilities etc.)

    It’s funny – I’ve used urxvtd and urxvtc for a while – even on a system with 4GB RAM. (I’m a graphic designer and Adobe’s apps are notoriously RAM hungry) It simply makes sense to me, I suppose, to have a daemon that controls all of my term emulators.

  3. 3 AlBundy 2009/08/30 at 11:31 PM

    QUOTE
    I have always resented the fact that my terminal-based systems running under X incur a rather hefty price in the way of one instance of urxvt per application, which in turn implies one instance of bash per application.
    /QUOTE

    That is not true.

    You can always invoke a command like this:
    xterm -e /usr/bin/vim
    from some menu or shortcut of your desktop, and you will get a terminal application running under a X terminal, WITHOUT bash or any other shell.

    You can replace xterm with your favourite X terminal, but you need check if the option is also named “-e”.

  4. 5 Eric Fraga 2009/09/09 at 5:41 AM

    The other alternative, although I am not sure of the exact memory hit, would be use one xterm with screen?


  1. 1 Using dmenu with xft fonts « Motho ke motho ka botho Trackback on 2009/08/26 at 8:33 AM
  2. 2 X and Openbox in 12Mb « Motho ke motho ka botho Trackback on 2010/08/13 at 9:07 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Welcome!



Visit the Wiki!

Some recent desktops


May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF
 


May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games


Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers

License

This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,960,597 hits

Archives


Follow

Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: