The only solution for this is to decrease your memory usage in your program. The Java VM is throwing that error because it has run out of resources to do what you asked it to. Maybe you have some large resources (like images or a large cache) that you could minimize? In any case, you'll have to slim down your program or increase the heap size.
You can't do that explicitly. Java WILL do it for you if you dereference the array (set it to null) as well as all elements of the array (if they are objects). The java virtual machine is required to garbage collect as much memory as it can before it throws an OutOfMemoryError. Just make sure you aren't keeping references to your objects around longer than you need to and then you just have to trust java to do its job.