2-dimensional array of longs and memory issues

I was a little reluctant to post the code, because: A) Its kind of long, so it seems like a lot to ask for anyone to read it through. B) It's kind of messy, not exactly my proudest work.

But here it is (had to use pastebin because it exceeded the max post size for this forum):
http://pastebin.com/0TtW04P9