0

So, I've been using an hp media center for a while and only have about 4 gigabytes of ram so, of course, I'm running a 32 bit windows 7. I keep trying to run a program that uses the java virtual machine and I can use jvm arguements with it, but, I need more heal space and since I don't have enough ram, I heard that it was possible to make programs use swap instead of or alongside ram. So, is there a jvm arguement or program that I can use to make a program use ram and swap or just swap? Any reply is appreciated hat could help. And before anyone says it, yes, I know swap is slower than ram since I'm using a regular HDD.

  • If I understood your question correctly, you are using a 32-bit OS, which implies a 32-bit JVM. I believe the maximum memory that may be allocated to the JVM is therefore 4GB (see http://stackoverflow.com/questions/1434779/maximum-java-heap-size-of-a-32-bit-jvm-on-a-64-bit-os). Even if you allocate 4GB, the O/S may swap some portions to disk. – KevinO Apr 06 '17 at 19:23

1 Answers1

1

This is not about a jvm argument as far as I know. Heap for the jvm process is taken from the OS it runs under. That's taken from the virtual memory which already include swap space if you have such. How much swap is your OS having is entirely a configuration of that particular OS. Since you are running windows of 32 bits, your jvm is 32 bits also. And a 32 bits JVM can theoretically use up to 4GB of RAM; on the practice it's not more then 1.3GB (as noted in comments) usually; so adding swap will not make your life easier. First you do need a 64 bit OS.

Eugene
  • 117,005
  • 15
  • 201
  • 306
  • 1
    Even the theoretical limit is only 3 GiB for 32 bit process on Window 7, which, however, will also contain code, I/O buffers and other non-heap data. But the JVM implementation is not capable of using more than 2 GiB (the lower address space) for the heap anyway. From that, you have to subtract code and data of native libraries without the “largeaddressaware” flag, so you are very lucky, if you get 1.6 GiB, usually, it’s more like 1.3 GiB. – Holger Apr 07 '17 at 13:28
  • @Holger to be honest I have not even tried to see how much I would get. It was something I remember seeing, so took it as granted. Will update. – Eugene Apr 07 '17 at 13:31
  • 1
    We had that issue with customers. One reason to still use a 32bit JVM was the jdbc-odbc bridge and the odbc drivers were not “largeaddressaware”, so the usable heap dropped when they were loaded or the other way round, when you enforced a maximum heap of, say, 1.4GiB to 1.5GiB, loading the drivers failed due to lack of native resources. But the libraries (or their versions) used by the JVM seemed to change in every update as well, so it always was a trial and error to find the maximum heap (and every byte counted, it really had performance impacts). – Holger Apr 07 '17 at 13:38