On Nov 19, 1:12*pm, Tom Anderson <t...@urchin.earth.li> wrote:
> On Wed, 19 Nov 2008, Owen Jacobson wrote:
> > On Nov 19, 11:48*am, Roedy Green <see_webs...@mindprod.com.invalid>
> > wrote:
>
> >> I have always avoided writing Java programs than run all the time and
> >> sporadically wake up to do something, e.g. test if a website is up,
> >> check for mail, do a backup ...
>
> >> I figured the overhead would be unacceptable.
>
> I'd also avoid it, but not out of concern for efficiency - for robustness..
> With a sleeping-looping program, if it crashes or gets wedged or
> something, it stops doing its job. With a program that does the job once
> and exits, but which is scheduled by cron or similar, the worst a crash or
> hang can do is clobber one run. It would take a failure of cron itself to
> stop future runs, and cron is something that i'm willing to bet the farm
> on.
>
> I guess you could use some external utility to monitor your looping
> program and restart it if it crashes. I think you can do that with init on
> unix (?), or launchd on a Mac, or you can just write a shell script which
> invokes the program in a loop. Doesn't really help with hangs, though. You
> could use some sort of watchdog mechanism for that.
>
>
>
> >> Though I never tested it. *Has anyone ever measured just how much of a
> >> drain such a sleeping program puts on resources?
>
> > I run Tomcat to host Hudson and JIRA for my own development on a linux
> > machine stashed in a corner. When no builds are running and I'm not
> > actively fiddling with JIRA issues, the machine's load averages are
> > effectively 0.00 0.00 0.00. I was a little leery of having a Java
> > server running constantly for pretty much the same reasons, but it
> > actually works rather well.
>
> > For reference:
> > JAVA_OPTS="-Djava.awt.headless=true -Xmx512M \
> > *-Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_B UFFER=true"
> > JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.10
>
> > Care of ps(1), the rss and vsize:
> > rss = 111800 (111 MB), vsize = 695512 (696 MB)
> > which makes it by far the largest process (for both resident and
> > virtual size) on the system, but with several GB of RAM I can afford
> > 100MB.
>
> I'm slightly surprised it uses 100 MB of memory even when not running. Is
> that because there's nothing else running on that machine, or at any rate,
> not a lot of memory pressure? Would that get paged out if there was, or is
> it some kind of pinned/wired memory?
>
> tom
There's a lot of crap running on that machine (apache2, tomcat, mysql
for some webapps, postgresql for my own apps, slapd, sshd, and a few
long-standing screen sessions) for one user, but it's not busy by any
stretch. The load average rarely breaks 1.0.
Computing range(1, 0x0FFFFFFF) in python (which allocates a really
huge array) forces Tomcat's resident size down to 5916 (6 MB). It also
beats the crap out of the CPU.
-o