Wednesday, July 13, 2011

Grails memory leak

I'm developing a Grails based application recently and I've came across several "problems" of the framework itself.

One of them was related to a process that needed to persist a lot of objects (300000). As it is explained here a memory leak could occur when a lot of objects are saved without cleaning the hibernate session and the DomainClassGrailsPlugin.PROPERTY_INSTANCE_MAP (which holds the validation results).

An additional advice about this is to make sure the process in charge of saving the data is run on a separate thread, different from the thread request. If it is executed using the request thread the DomainClassGrailsPlugin.PROPERTY_INSTANCE_MAP.get().clear() doesn't have any effect as the errors will be saved in the thread request instead, thus possibly causing an out of memory error.

No comments:

Post a Comment