Index: /trunk/grails-app/services/AssetCsvService.groovy
===================================================================
--- /trunk/grails-app/services/AssetCsvService.groovy	(revision 423)
+++ /trunk/grails-app/services/AssetCsvService.groovy	(revision 424)
@@ -1,2 +1,3 @@
+import grails.util.GrailsUtil
 import au.com.bytecode.opencsv.CSVWriter
 import au.com.bytecode.opencsv.CSVReader
@@ -12,4 +13,7 @@
 
     def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib()
+
+    def sessionFactory
+    def propertyInstanceMap = org.codehaus.groovy.grails.plugins.DomainClassGrailsPlugin.PROPERTY_INSTANCE_MAP
 
     /**
@@ -259,4 +263,7 @@
 
                 } // while( nextColumn() )
+
+                if(lineNumber % 100 == 0)
+                    cleanUpGorm()
 
                 nextLine()
@@ -448,3 +455,17 @@
     }
 
+    /**
+    * This cleans up the hibernate session and a grails map.
+    * For more info see: http://naleid.com/blog/2009/10/01/batch-import-performance-with-grails-and-mysql/
+    * The hibernate session flush is normal for hibernate.
+    * The map is apparently used by grails for domain object validation errors.
+    * A starting point for clean up is every 100 objects.
+    */
+    def cleanUpGorm() {
+        def session = sessionFactory.currentSession
+        session.flush()
+        session.clear()
+        propertyInstanceMap.get().clear()
+    }
+
 } // end class
