1

I am using 32 bit version of Java in windows 7 64 bits. The system has a RAM of 6 GB. But when JVM is allocated memory by OS, it doesnot goes beyond 1.5 GB (same as in 32 bit OS). What are the possible reasons, that JVM is not allowed sufficient memory. And if possible how to fix it? I cannot upgrade to 64 bit JVM.

Reporter
  • 3,897
  • 5
  • 33
  • 47
user2531191
  • 579
  • 10
  • 27
  • 2
    Why can't you upgrade? – Troubleshoot Oct 10 '13 at 08:05
  • It's 32-bit app so it won't get more memory than on 32-bit OS. I don't know if the limit of memory area for app is 2 or 3GB on Windows... JVM has memory for objects, stack and classes, you probably refer only the first. – Danubian Sailor Oct 10 '13 at 08:06
  • @Troubleshoot maybe some program does not run with 64bit version – Reporter Oct 10 '13 at 08:07
  • 1
    @Troubleshoot There can be many valid reasons, for example the use of a native DLL. – Denys Séguret Oct 10 '13 at 08:07
  • Are you speaking of the initially allocated memory or of the maximal usable memory ? – Denys Séguret Oct 10 '13 at 08:08
  • @dystroy maximum usable memory. there are some reasons like using some native libraries and database drivers (DLL) so I cannot upgrade. Beyond a point I will get outofmemory error - cannot allocate further memory to create threads etc. – user2531191 Oct 10 '13 at 08:12

4 Answers4

2

A 32-bit process on Windows is still subject to the same limits as running on a 32-bit Windows OS. See the answers to this question.

How much memory can a 32 bit process access on a 64 bit operating system?

This guidance from Oracle suggests that a 32-bit JVM can use approximately 1.5GB.

The maximum theoretical heap limit for the 32-bit JVM is 4G. Due to various additional constraints such as available swap, kernel address space usage, memory fragmentation, and VM overhead, in practice the limit can be much lower. On most modern 32-bit Windows systems the maximum heap size will range from 1.4G to 1.6G.

Community
  • 1
  • 1
Steve
  • 7,171
  • 2
  • 30
  • 52
1

As indicated by this article:

The default maximum heap space is 1/2 of physical memory of size upto 192 bytes and 1/4th of physical memory for size up to 1G.

I know you have more than 1G, but maybe this also applies for you

Matt
  • 74,352
  • 26
  • 153
  • 180
angel_navarro
  • 1,757
  • 10
  • 11
1

32 bit application will not be able to use more that 4GB of RAM. In practice, it will not be able to use more than 3GB because it needs some virtual memory space reserved for operating system.

Besides that, by default JVM allocates up to a quarter of available RAM. If you want to override this use option:

java -XX:DefaultMaxRAMFraction=1

It should use all available RAM that is feasible for 32 bit application.

Source: http://jvm-options.tech.xebia.fr/#

Grzegorz Żur
  • 47,257
  • 14
  • 109
  • 105
1

To be able to use more memory you have to upgrade to 64 bits. Unfortunately a 64 bit JVM cannot load 32 bit dlls, so the calls to the dll must be made from a different process, and you have to use an rpc mechanism to talk with the process instead of using the dll directly. It's a lot. of work but it can be done.

Joni
  • 108,737
  • 14
  • 143
  • 193