memory usage of grails application - grails

I want to know about how much memory can a grails application use.
Does it depend on the number of domain classes, plugins installed?
I am develpoing an application and when I test it on tomcat it continuously goes out of memory.
currently using almost 500MB.
Moreover if this is not the case, can you suggest me what methods of memory management can be used?

Have a look at the Grails Java Melody plugin. It will give you all kinds of statistics on your running app, in your case the memory stats should help but there is so much more to this Swiss Army knife of app monitoring.
Initially have you tried playing with JVM settings eg: -XX:PermSize=256m -XX:MaxPermSize=1g -Xms256m -Xmx512m

Java, and Groovy, and Grails have very high level of minimal usage of memory. 500Mb is really small amount, and it's pretty common to start from 1Gb (I mean tomcat memory configuration). So, don't worry about 500Mb, it's ok.
As about domains, classes, etc - of course all new classes, all new code, it requires some memory, but i'm sure that for your case it's just a few percents of memory, all other is used by Grails libraries, Tomcat, JVM, etc.
PS there is also common Tomcat problem with PermGem space - https://stackoverflow.com/search?q=permgem+space

Related

Memory requirements for WildFly

I never found an official documentation about it and I generally install WildFly 8.x on servers with, at least, 4GB.
How much memory should my server have in order to run a WildFly instance?
Is there a minimum recommended?
The minimum value of Xmx is the one that let you start an empty instance of WildFly. On my try, it is 24 MB. There is no other valid value for a minimal Xmx. 4g is a totally arbitrary value. It's absolutely depending on your application, on the number of user,...
You have to run a stress test on your application and measure the memory. It is the only way to know the minimum for your application.
That depends on your application requirement.
In general I would recommend 4GB as a minimum. Note that you should have enough memory for the OS and it's caches.
Some small applications run perfect with <1GB for WildFly some need >32GB as they have lots of data.
So it's on you and you should test and measure it.
Along with the other answers I'd like to add a few points.
This would also depend upon :
Are you running the server in domain mode or standalone mode ?
Do you want all the components of the profile you are running the server with? If not you can create custom profile by removing unwanted components.
How many apps do you plan to deploy on the server ?
What is your performance/availability requirements ?
You need not always need 4GB ram, we run wildfly on our production servers with min memory set to 512MB and max as 1GB, till date no memory issues :)

Portable Development Environment

I am working on a huge Grails Project, and more and more people are going to be working on it.
The problem is that I have been spending ages setting up people's machines (java etc etc).
I heard that there is something like a VM that you can set up on your machine once and transfer on other people's computers.
Also what about performance issues? Lets say I install a VM on other people machine that will slow down things no?
Yes it will be very bad in performance as VM runs as a full fledged machine with OS on top of it. If you have all systems with very high configuration like quad-core i7's and minimum of 8Gb rams then only systems will be able to handle such load.
Still it will be a bad idea to do so. And while running grails you already have multiple instances of java running like in my case with netbeans I have 2 resource hungry java instances running with 700mb and 500mb respectively.

What is the minimum memory footprint for a simple grails application?

We are deploying a simple REST grails (2.3.7) app to heroku. The application is doing little less than "Hello World", yet we exceed the 1x dyno limit of 512MB (usually going between 600-700MB).
What is the expectation of memory usage of such an application?
Also, is there an official minimum requirements concerning memory?
Currently the minimum for a basic application is around or just above the 512mb amount depending on what the app does. We are aware of the problems this creates for Heroku and currently you need double dynos to run Grails applications on Heroku.
We are working to improve Grails support for micro services and a smaller memory footprint in Grails 3.0.
See this question stackoverflow :
memory usage of grails application
and what i can say is based on
If memory is not a problem on your server then allocate a large amount of memory, such as 512M or more. Also use the server VM option. EG: (-server -Xms512M -Xmx512M). Usually it is better to set both min and max heap size to the same in server applications.
However, if you running on a virtual host with limited memory, Grails 1.0 RC1 has been tested on tomcat 6 with both -Xmx96M and -Xmx128M, it performed well with both settings. I've heard reports of it running on lesser configurations"
And , REST application memory requirement can be high according to the request and how complex query and results involved, And also how you managed to do the coding that you properly cleared out every session , object after use ? But , i guess for REST application one > 512 <= 1GB of memory is good to start. And , use so tweaks for memory as well. it should be fine!

Tomcat per webapp memory settings

I am having two webapplication running inside tomcat. Java Heap space is allocated for Tomcat and it is shared for both appliaction. In that one application consumes more and other is getting OUT_OF_MEMORY.
Is there any way to set memory settings per web application. Say 70% for one webapp and 30% for other from the overall memory allocated to Tomcat.
Regards
Ganesh
The memory is defined per JVM instance, so if you are using one tomcat you cannot do it.
However you can run two tomcat instances - one per web application - and then you will finer control on memory allocation for each webapp.
No. There is no way for some portion of java code to control the consumption of memory by other portion of code called from first portion of code. In other words, the web container is just a java program which calls some other java class methods found in application.
So the only control one has is JVM arguments. And this arguments are only to hint the JVM where approximately to fail with out of memory error. No, it is not possible.

make full use of 24G memory for jboss

we have a solaris sparc 64 bit running the jboss. it has 24G mem. but because of JVM limitation, i can only set to JAVA_OPTS="-server -Xms256m -Xmx3600m -XX:MaxPermSize=3600m".
i don't know the exactly cap. but if i set to 4000m, java won't like it.
is there any way to use this 24G mem fully or more efficiently?
if i use cluster on one machine, is it stable? it need rewrite some part of code, i heard.
All 32-bit processes are limited to 4 gigabytes of addressable memory. 2^32 == 4 gibi.
If you can run jboss as a 64-bit process (usually just adding "-d64" to JAVA_OPTS), then you can tune jboss with increased thread and object pools to make use of that memory. As others have mentioned, you might have horrific garbage collection pauses, but you may be able to figure out how to avoid those with some load testing and the right choice of garbage collection algorithms.
If you have to run as a 32-bit process, then yes, you can at least run multiple instances of jboss on the same server. In your case, there's three options: zones, virtual interfaces, and port binding.
Solaris Zones
Since you're running solaris, it's relatively easy to create virtual servers ("non-global zones") and install jboss in each one just like you would the real server.
Multi-homing
Configure an extra IP address for each jboss instance you want to run (usually by adding virtual interfaces, but you could also install extra NICs) and bind each instance of jboss to its own IP address with the "-b" startup option.
Service Binding Manager
This is the most complicated / brittle option, but at least it requires no OS changes.
Whether or not to actually configure the jboss instances as a cluster depends on your application. One benefit is the ability to use http session failover. One downside is cluster merge issues if your application is unstable or tends to become unresponsive for periods of time.
You mention your application is slow; before you go too far down any of these paths, try to understand where your bottlenecks are. Use jvisualvm or jstat to observe if you're doing frequent garbage collections. If you're not, then adding heap memory or extra jboss instances may not resolve your performance woes.
you can't use the full physical memory, JVM requires max contined memory trunck, try use java -Xmxnnnnm -version to test the max available memory on your box.

Resources