0

I just can't figure it out, why i get this error. It is not always shown, but once it appears, my application refuses to accept connections (can't create new Socket-Threads, and also other threads i create in my JAVA-application for some of them i use ThreadPool).

top and htop shows me, there is ~ 900 MB of 2048MB used. and there is also enough heap memory, about 200MB free.

cat /proc/sys/kernel/threads-max outputs:

1196032

and also, everything worked fine few days ago, it's a multiplayer-online game, and we had over 200 users online(~500 threads in total). But now even with 80 users online(~200 threads) after 10 min or few hours my application gets somehow broken with this OutOfMemoryError. In this case i do restart my application and again it works only for this short period of time.

I am very curious about, what if JVM act strangely on VPS, since other VPS on the same physical machine do also use JVM. Is that even possible? Is there some sort of limit by provider what is not visible to me? Or is there some sort of server attack?

I should also mention, by the time this error occours, sometimes munin fails to log the data for about only 10 min. Looking at graph-images, there is just white-space, like munin is not working at all. And again there is about 1 GB memory free as htop tells me by that time.

It might be also we case, i somehow produced a bug in my application. And start getting this error after I've done update. But even so, where do i begin the debugging ?

6
  • Post your VM options, they are essential in a situation like this. "what if JVM act strangely on VPS, since other VPS on the same physical machine do also use JVM. Is that even possible? Is there some sort of limit by provider what is not visible to me? Or is there some sort of server attack?": no, no, maybe. Commented Dec 2, 2011 at 14:48
  • it has been run with "-Xms256m -Xmx256m" and "-Xms256m -Xmx256m -XX:MaxPermSize=256m -Xss128k"... both produce same result Commented Dec 2, 2011 at 14:53
  • Those values seem rather small for a game server, you could double them if you have that much free memory. But since it worked fine until recently, your problem likely lies elsewhere: probably some software configuration changed in your VPS. You have to understand what changed since those few days ago. Commented Dec 2, 2011 at 14:58
  • i used these small values 256mb, since the java(heap) uses 50mb at most. I keep this values small, because i need more ram for creating Threads. I have figured that out few months ago while our server had only 1 GB total memory. To understand what has changed, is a real Problem. I've put even old-version of my application, and still getting same error. Commented Dec 2, 2011 at 15:06
  • Try setting max heap to some larger value and see if you get back to the runtime performance (200 users, not crashing) that you expect. Since you mention that you just did a code update, you need to look at what you've done. Perhaps you are creating memory leaks or other garbage that is being held for too long. You could also try to roll back to your previous version to see if go back to your expected performance, which ought to pin the error to your code changes. Commented Dec 3, 2011 at 17:47

4 Answers 4

1

try increasing the stack size (-Xss)

Sign up to request clarification or add additional context in comments.

3 Comments

well tried with -Xss2048k as expected my application ate lots of memory, but... there was about 500 MB free. But it still didn't help. Besides, trying to execute via SSH "less" or "htop" i got message "-bash: fork: Cannot allocate memory". I had in other terminal already another SSH connection and "htop" were was permenanetly running and showing there is about 500 MB free. I am really confused! seems OperationSystem or VPS brocken?
i am not rally an expert on VPS, but a quick google search takes me to this link
as i wrote in my answer(to myself), it describes that problem. I like how the author describes in link you have found thumb up. But i guess that can do only admins from providers? I still have access to VPS, and from inside(VPS OS) was not able to find these settings to change.
1

You seem to host your app in some remote vps server. Are you sure the server, not your development box, has sufficient ram. People very often confuse their own machine with the remote machine.

Because if Bash is running out of memory too, is obviously a System Memory issue, not an App Memory issue. Post the results of free -m and ulimit -a on the remote machine to get more data.

If you distrust yout your provider to be using some troyanized htop, free and ulimit , you can test the real available memory with a simple C progran where you allocate with malloc 70~80% of your available ram and assigning random bytes on it in no more than 10 lines of ANSI C code. You can compile it statically on your box to avoid any crooked libc, and then transfer it with scp. That being said I heard rumors of vps providers giving less than promised but never encounter any.

1 Comment

yes, am sure it's a VPS giving me such an error. I myself running 8 Gigs of RAM on gentoo 64bit. Though i am poor with C-knowledge, but I like the idea with malloc! But as support from provider told it might be bug how OpenVZ interacts with JVM(they are not sure aswell). Well in few days i know more, because we decided to move to dedicated server.
0

Well moving from a VPS to a dedicated server solved my problem. Additionally i found this

https://serverfault.com/questions/168080/java-vm-problem-in-openvz

this might be exactly the case, because on VPS i had there was really too low value for "privvmpages". It seems there is really some weird JVM behaviour in VPS. As i already wrote in comments, even other programs(ls, top, htop, less) were not able to start at some time, although enough memory were available/free. And.. provider did really made some changes on their System.

And also thank you everyone, for very fast reply and helping me solving this mystery.

Comments

0

You should try JRockit VM it is work perfect on my OpenVZ VPS, it consumes memory much less then Sun/Oracle jvm.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.