I deployed a Grails application that I built (first application I've made) that starts up with a memory usage of roughly 2 GB. (Tomcat 6)
The application maintains roughly 133,000 domain objects between 4 types. Most transactions to the DB are searches through about 115,000 of those objects and normal CRUD operations/file import and export.
After much usage, I see that my memory stamp is 3.3 GB.
First off - Why is the memory usage so high at start up? Does Grails by default cache domain object usage in memory?
Second - I've handled GORM cleanup at numerous points in the application, but the memory usage is still high (3.3GB). Is there something in the ORM layer that causes caching of transactions, etc?
Thanks
---------------Edit--------------------
Test: I removed all domain objects from the database
Startup: 514 MB
With objects: 993 MB (I trimmed some performance based on the DataSource file)
** Data Source **
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "xxx"
password = "xxx"
}
hibernate {
cache.use_second_level_cache = false
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost/mydb"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost/mydb"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost/mydb"
}
}
}
JVM options:
-server -Xms512m -Xmx1048M -XX:MaxPermSize=1048m -XX:+UseParallelGC -XX:-UseGCOverheadLimit
JavaMelody and perf4j: -to help you see where/what/how is your memory usage
See this http://burtbeckwith.com/blog/?p=73 and this http://grails.1312388.n4.nabble.com/Memory-leak-td1358871.html and this http://www.componentix.com/blog/8/run-long-batch-processing-jobs-in-grails-without-memory-leaks