1

I was working on a kind of SMTP kinda protocol, I made it in java and run successfully. It was consuming about 20 to 30 MB in my laptop. Later I decided to make the protocol live on internet. I purchased the servers(VPS), domain. It costed me a lot. But when I tried to run my program over that server I was so shocked that my program was consumption about 800 to 900 MB for each class I was running. I thought it may be my programming fault, I tried a lot to recover from problem but I could not. Later a friend of mine suggested me to test a simple Hello word program on same server, I was so shocked that even that program was eating up to 900 MB of my total RAM.

What kinda of problem can it be ? Is it the fault in those servers, or their OS and kernels versions ? Is it problem of JVM with Linux kernels or older linux kernels. I have even tried with older JVMs but no use. :(

I tried most of popular flavors of Linux but it worked same and had exactly same problem on all Linux flavors. Was eating huge memory in all cases. ( All of them had Linux kernel 2.6.xx)

But it worked very smooth and consumed expected memory in my laptop. (about 30 to 50 Mb). I use Linux in my laptop. But the difference is that my kernel is above 3.1.xx . Can it be the problem ? I am really so disappointed with behavior of my servers and have lost lots of money in it. Please anybody tell me the possible solutions, can it be the problem of Linux kernel or its problem in my programming.

HoldOffHunger
  • 10,963
  • 6
  • 53
  • 100
Point Networks
  • 851
  • 8
  • 29
  • 2
    The amount used depends on the JVM, what parameters you use and [how much memory you have on the system](http://stackoverflow.com/questions/4667483/how-is-the-default-java-heap-size-determined), among other things. Do you provide specific -Xmx/-Xms parameters? – assylias Mar 24 '13 at 18:23
  • 1
    Maybe that's the JVM's **reserved** memory, not real memory consumed by your app. – m0skit0 Mar 24 '13 at 18:24
  • Did you try `java -server` on your laptop? See [here](http://stackoverflow.com/questions/198577/real-differences-between-java-server-and-java-client), but the point is, the running in server mode has some overhead paying itself back under normal server operation. (Another idea) – Joop Eggen Mar 24 '13 at 18:29
  • To asslias : No I dont provide any of such parametrs – Point Networks Mar 24 '13 at 18:36
  • To m0skit0 : If it would be momory taken by JVM only ,, then I think it would not have taken same memory again and again for each instance of that program. – Point Networks Mar 24 '13 at 18:37
  • to Joop : No I haven't tried java server. But do u think starting java-server can reduce memory load ? – Point Networks Mar 24 '13 at 18:39
  • No, I think using -server will make it worse. I think that option assumes you're running on a server-class machine with sufficient memory to keep more things in memory. Not everything in Java is about the heap: search SO and Google for "total resident memory". – duffymo Mar 24 '13 at 19:51

1 Answers1

0

Is your laptop running Windows? I'll assume that the answer is yes. The memory values you see reported in Windows Task Manager are not what Linux reports for total resident memory.

I don't believe that Hello World is taking up 900 MB. If it is, that tells me that the JVM memory is being reported, not your app.

Are you running this app on a Java EE app server like Tomcat or JBOSS? That will make a very big difference indeed.

The best advice is to search SO for other questions that showed how to use Linux tools like nmap to figure out where memory is being consumed.

duffymo
  • 293,097
  • 41
  • 348
  • 541
  • No, I am using Linux on my laptop. And it takes about 30 to 40 MB of my laptop for same program but is taking more than 700 to 800 Mb on server. And yeah even I was shocked to see the response of Hello word program .. but its true that it was taking about 900 MB – Point Networks Mar 24 '13 at 18:32
  • Do you have -server option turned on for both laptop and computer? – duffymo Mar 24 '13 at 19:50
  • I know of a web app that runs on Red Hat Linux with -server turned on that consumes 2.8GB of total resident memory. It runs on JBOSS 5.1.1. If I profile it, I find that the app uses little memory. It's JBOSS, the JARs it maps into resident memory, threads, etc. There's more going on than your app. The same app runs on Tomcat 6.x in 40% of the JBOSS 5.1.1 total memory. – duffymo Mar 24 '13 at 19:53
  • no I do have server option turned on. Does that matter in such case ? – Point Networks Mar 25 '13 at 10:56