Check this article. It seems to do a good job describing the optimization process, and it has example code (Java and C) to access / change the sizes. There's also a link to a Linux tool to determine optimum size.
This other article show some things you can access using the /proc/sys file system, which is a nice source for real-time info. It shows how to use it using the command line.