Contact SalesSitemapCustomer Login

Warning: mysql_connect() [/function.mysql-connect]: Can't connect to MySQL server on 'coredb-01.spry.com' (13) in [path]/vpslink_template_files/contextual_ads.inc.php on line 56

Go Back   VPSlink Forums > Technical Discussion > Linux

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-26-2007, 09:26 PM
Junior Member
 
Join Date: Feb 2007
Posts: 2
Default Java - Could not reserve enough space for object heap

Hi,

I'm having some trouble getting a java app to work. Obviously on a VPS the memory setup is a little different to normal, but even the following doesn't work:

root@server:/# java -Xms16m -Xmx32m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

I'm on a lowly Link1 plan with 64Mb RAM but surely this should still work? Any ideas?

Cheers.
Reply With Quote
  #2 (permalink)  
Old 02-26-2007, 11:41 PM
Senior Member
 
Join Date: May 2006
Location: Toronto,Canada
Posts: 103
Default

Hi

I've discussed this issue and written some tips/tricks:

http://www.jeveloper.com/blog/2007/0...639380000.html

Comment on it so i can get back quicker.

We also discussed this on this thread:

J2EE Application Servers

Regards,

Serge
__________________
www.getbriefed.net - Store web notes
Reply With Quote
  #3 (permalink)  
Old 02-27-2007, 06:28 PM
Junior Member
 
Join Date: Feb 2007
Posts: 2
Default

Hi Serge,

I have actually come across your article already but it doesn't seem to offer a solution to my problem so far as I can see.

I ran the script to show free memory and it comes back with 48mb as below:

VPS Memory:
total: 58 mb used: 10 mb free: 48 mb

So, with 48mb free I should be ok with -Xmx32m right? I'm not even trying to run anything yet, just getting the version number would be a start.

Even with 'java -Xms12m -Xmx16m -version' I still get the same error as before...
Reply With Quote
  #4 (permalink)  
Old 02-27-2007, 06:50 PM
Senior Member
 
Join Date: Aug 2006
Posts: 1,021
Default

Remember that heap space isn't *all* it consumes --- that's just a maximum of heap space (it can and will use additional memory beyond that). You'll be very lucky if you can spin up a java process in 48MB of memory, or on a Link 1 for that matter.
Reply With Quote
  #5 (permalink)  
Old 03-01-2007, 02:54 AM
Senior Member
 
Join Date: May 2006
Location: Toronto,Canada
Posts: 103
Default

Quote:
Originally Posted by rhubarb
Hi Serge,

I have actually come across your article already but it doesn't seem to offer a solution to my problem so far as I can see.

I ran the script to show free memory and it comes back with 48mb as below:

VPS Memory:
total: 58 mb used: 10 mb free: 48 mb

So, with 48mb free I should be ok with -Xmx32m right? I'm not even trying to run anything yet, just getting the version number would be a start.

Even with 'java -Xms12m -Xmx16m -version' I still get the same error as before...

Is my english that bad?
I wrote a thousand times that -Xmx32m will not force JVM to use JUST 32 megs and no more, of course not.

and Xms is the initial heap size, can be set to just 2 megs or even in Kilobytes with "K"

Experiment, see what will work for you.

Tomcat should be runnable but you won't be able to do much since MySQL even with minimum settings would need 30 megs or more of ram which you don't have.
__________________
www.getbriefed.net - Store web notes
Reply With Quote
  #6 (permalink)  
Old 03-29-2007, 09:26 AM
Junior Member
 
Join Date: Mar 2007
Posts: 1
Unhappy Java on Link2

I have a link2 plan and have been trying to get Java to run.

I have read all the threads in this forum, jeveloper's blog and numerous other Internet offerings. However despite what exotic jvm parameters i set java will not load and in all situations will simply state.

[root@vps bin]# ./java -client
Picked up _JAVA_OPTIONS: -Xms4m -Xmx8m
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Btw this is the same result on ubuntu, debian and fedora core.

On each attempt to run java the failcnt will increase on privvmpages indicating that the jvm is trying to reserve more memory than i have specified. Yes I know jvm has other memory requirements in addition to those of heap allocation but they should not be this vast.

resource held maxheld barrier limit failcnt
privvmpages 5864 16613 29720 29720 2


My impression from what I have observed and read from the various sources is that Sun Java is simply not compatible with OpenVZ in a highly memory restricted environment. With openVZ not hiding the underlying system resources and Java not doing what it is told when it sees vast amounts of resources.

This kinda sucks in my opinion as its not unreasonable to expect to run a simple Java process with 108mb of memory free.

If anyone has had any success in running Sun Java on a link2 plan I would love to hear *exactly* how, and if anyone could assure me that if I upgrade to link3 plan I would be able to get Java running. Or if anyone has any additional thoughts into how to reign in the JVM to doing what it is told.
Reply With Quote
  #7 (permalink)  
Old 07-23-2007, 05:30 PM
Junior Member
 
Join Date: Jul 2007
Posts: 5
Default

It's been almost four months since the last post on this thread. Has anyone learned anything about running Java on a Link2 plan?
Reply With Quote
  #8 (permalink)  
Old 07-24-2007, 08:31 AM
Junior Member
 
Join Date: Jun 2007
Posts: 16
Default

Quote:
Originally Posted by Kintar View Post
It's been almost four months since the last post on this thread. Has anyone learned anything about running Java on a Link2 plan?
It won't work, probably. Java maps a lot of files to virtual memory, besides JIT-ed classes take a lot of space.

I've got the best results from this command:
Quote:
export _JAVA_OPTIONS="-Xms20m -Xmx64m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:NewSize=10m -XX:MaxNewSize=10m -XX:SurvivorRatio=6 -XX:TargetSurvivorRatio=80 -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"
Reply With Quote
  #9 (permalink)  
Old 07-24-2007, 02:07 PM
Junior Member
 
Join Date: Jul 2007
Posts: 5
Default

Sadly, this isn't a problem with available memory. I have gotten Java to run fine on a VM at home that only has 128MB of RAM. The problem appears to be that OpenVZ by default shows the entire available ram on the hardware to the VM, and Java gets terribly, horribly confused about this. No amount of heap-space and garbage-collection related command line arguments will resolve this issue. I've seen some forum postings about changing the way OpenVZ reports system memory to the virtual machines, but of course that requires root access to the host OS.
Reply With Quote
  #10 (permalink)  
Old 07-24-2007, 02:40 PM
Junior Member
 
Join Date: Jul 2007
Posts: 5
Default A solution!

I'm not terribly happy about it, but it works.

If you're okay using a 1.4 VM, and don't need some of the security APIs for validating untrusted code, then check out Kaffe (it's www dot kaffe dot org). It's a completely non-Sun version of the Java VM, is included in apt, and will actually run on a Link-2 plan.

Now that I'm POSTIVIE this is an issue with the Sun VM and OpenVZ, I'm going to look for other Java implementations that might work, but provide full compatibility with Sun Java.

And, now that it's proven that it's a problem with OpenVZ reporting memory in a weird way to the Sun VM, could we please have a VPSLink person look at possible changes to the configuration that will correctly report memory to the guest OSes?

-- Kintar
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT. The time now is 11:28 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0