Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory consumption for java web app (300MB too high?)

Can I pick your brains about a memory issue?

My java app, which isn't huge (like 14000 LOC) is using about 300MB of memory. It's running on Tomcat with a MySQL database. I'm using Hibernate, Spring and Velocity.

It doesn't seem to have any leaks, cause it stabilizes and 300MB, without growing further. (Also, I done some profiling.) There's been some concern from my team, however, about the amount of space it's using. Does this seem high. Do you have any suggestions for ways to shrink it?

Any thoughts are appreciated.

Joe

like image 428
Joe Avatar asked Mar 05 '12 21:03

Joe


2 Answers

The number of LOC is not an indicator of how much heap a Java app is going to use; there is no correlation from one to the other.

300MB is not particularly large for a server application that is caching data, but it is somewhat large for an application that is not holding any type of cached or session data (but since this includes the webserver itself, 300MB is generally reasonable).

like image 189
Trevor Freeman Avatar answered Sep 19 '22 19:09

Trevor Freeman


The amount of code (LOCs) rarely has much impact on the memory usage of your application, after all, it's the variables and objects stored that take most of the memory. To me, 300 megabytes doesn't sound much, but of course it depends on your specific usage scenario:

  • How much memory does the production server have?
  • How many users are there with this amount of memory used?
  • How much does the memory usage grow per user session?
  • How many users are you expecting to be concurrently accessing the application in production use?

Based on these, you can do some calculations, eg. is your production environment ready to handle the amount of users you expect, do you need more hardware, do you perhaps need to serialize some data to disk/db etc.

like image 41
esaj Avatar answered Sep 21 '22 19:09

esaj