Hello, I'm java developer and work more than 3 years in that field.
I understand your problem with insufficient memory and already have a few solutions depending on situation. I would like to look for more details in order to resolve your problem, some of them are: full stack trace of error (including lines, classes etc), java program itself, how much heap memory was given to app (not very necessary).
Feel free to contact me, waiting for your response!