Running out of Memory with Java

The other day when doing some particularly large xslt conversions I kept running out of memory in the JVM. After doing a bit of research I found two command line arguments that help solve the problem. -mx allows you to set the maximum size of the memory allocation pool while -ms allows you to set the starting size.

For example:
java -ms50M -mx1000M ProgramThatNeedsLotsOfMemory

will execute ProgramThatNeedsLotsOfMemory with a starting memory allocation of 50M and let it grow up to 1GB. You can also use K to specify the memory size in kilobytes, but I’m not sure why that would be useful unless you are on a machine with very little memory.

After looking into the documentation a little more it appears that the new syntax for these commands is -Xms and -Xmx, so you’ll have to choose the one that works depending on your version of the JVM.

Home Theater

When we started looking at finishing the basement at our house, I really wanted to put in a home theater. Eventually we ended up with a 6 seat theater with a 12 foot screen and surround sound. The total cost was less than you might pay for a large screen television and it was a lot of fun to setup. Now instead of going to the theater and paying $6 to $8 per ticket, we rent a video and have friends over to the house. Here is how we set things up.

Yahoo has a credit card that earns points that can be redeemed for SuperCertificates that can be redeemed for Amazon.com gift certificates that can be redeemed for Amazon merchandise. It is rather round about, but we were able to get our projector for free using the method. It took 2 years of saving our points, but we weren’t in a hurry and it was a lot easier to justify the projector when we got it for free.

InFocus X2 Multimedia Projector ( PC / Mac )The projector is an InFocus X1A DLP Multimedia Video Projector. I believe it has now been replaced by the InFocus X2 Multimedia Projector which is a little brighter, but very similar. Both projectors have a theater mode that helps keep the color realistic like film. Many “business presentation” projectors distort the color in order to make a brighter image so they don’t look as good for watching movies. The X1 can handle a wide variety of inputs making it idea for a budget home theater where you may want to start with your existing components and upgrade in the future.
Continue reading “Home Theater”

Unix/Linux Cut Command

The cut command in unix lets you specify which part of a line you want to echo. For example if
cat file.txt
produces something like:

12345678
23456789
34567890

Cut can also be used to specify particular columns in tab, space or other delimited data.

then you could pipe the file into the cut command to show only the 3rd character like this:


cat file.txt | cut -c 3
3
4
5

You can also specify ranges like this:

cat file.txt | cut -c 3-4,6-8
34678
45789
56890

The Amazon Credit Card

Over the past 5 years I have ordered the following items from Amazon.com and received them for free:

My wife and use a credit card for most of our purchases. The credit card earns points that can be redeemed for merchandise at amazon.com, so every time we buy gas, groceries, pay for tuition, or go to the movies, we earn points that we can eventually redeem from Amazon. We keep track of our spending, and pay the entire bill at the end of each month, so it functions almost like a debit card and we don’t end up accumulating debt.
Continue reading “The Amazon Credit Card”