[nylug-talk] Free -m shows 300MB usage after upgrade to 1GB.

Lee Revell rlrevell at joe-job.com
Wed Jan 2 13:01:46 EST 2008


On Jan 2, 2008 12:53 PM, Chris Knadle <Chris.Knadle at coredump.us> wrote:
>    If this Java app really is using > 512MB then maybe something is wrong.
> Depends -- I don't know what the app is or how much RAM it's designed to use,
> etc.  It might very well be that it's doing what it's [mis]designed to do.
>
>    Java itself last I remember took about 32M or so to run the JVM.  I
> wouldn't jump to the conclusion that this was due to a problem with Java --
> it's more likely something to do with the application itself.
>

One issue is that Java likes to create a LOT of threads.  On Linux
each new thread allocates 8MB (or whatever RLIMIT_STACK is) of RAM for
the thread stack.  This is way, way too much for most use cases.

The docs for pthread_attr_setstack clearly state that the default
thread stack size should NOT be relied upon, but most multithreaded
apps seem to ignore this advice.

Try setting stack to something like 512KB in /etc/security/limits.conf
and rebooting.  I've seen this simple change cut the memory usage of
common apps by hundreds of MB.


>    And by definition it shouldn't matter what the OS is.  Wasn't that the
> point of Java?

Remember "Write once, run anywhere"?  Bwahahahaha...

Lee


More information about the nylug-talk mailing list