Monday, January 11, 2010

Shutdown Mac OS X with command line

I have founded that ordinary

$shutdown -p now

command line not enough to close Mac box. It doesn't turn the machine off.

After some googlings, I founded this The Command Line Junkie's Guide To Mac OS X,

which tell me that I can shut it down with command :

osascript -e 'tell application "Finder" to shut down'

Thursday, January 7, 2010

Java thread stack size

Today, I have just known that there's an another interesting parameter to set to JVM. It is java thread stack size.

With too high thread stack size, it will effect to low number of thread JVM can create - see this experiment. Not enough memory for java thread (cause from too big stack size) will produce "java.lang.OutOfMemoryError: unable to create new native thread"

You can set java stack thread size by adding -XssnK to JVM argument where n stands for a wanted size.

Now, I am not sure what is the default java thread stack size. Someone tells it is 512Kb. Another one tells it is up to the platform. One thing is that it's vary between each java versions. However, there is a way to get it from your running JVM. I got this trick from Get thread stack size at runtime thanks to claudio. Note that this trick may work only with *nix family.

First, you have to know your target JVM's pid (process id). If your system has only one JVM running, it is easy to use 'ps' or top to find it. But if it has many, my often used approach is to use

jps -lv

and justify it from the informations provided. If the informations are equally the same, help yourself :P.

Now you have target JVM's pid.

Then run following command

jinfo -flag ThreadStackSize {PID}

The jvm's set thread stack size will show to you in Kb.

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...