简体   繁体   English

java:如何在 32 位 JVM 中使用超过 4 GB 内存的堆

[英]java : How to use heap beyond 4 GB memory in 32 bit JVM

We have a product that runs currently on a 32 bit 1.6 JRE.我们有一个当前在 32 位 1.6 JRE 上运行的产品。 We're using Berkeley DB which consumes about 2.5 GB RAM of the 4 GB address space.我们正在使用 Berkeley DB,它在 4 GB 地址空间中消耗了大约 2.5 GB RAM。 That leaves us about 750 MB of memory for the JVM address space.这为 JVM 地址空间留下了大约 750 MB 的内存。

We're currently hitting OutOfMemory issues with the current setup.我们目前正在解决当前设置的 OutOfMemory 问题。 It would be nice to increase our JVM heap size to 1.5 GB while still retaining Berkeley DB's 2.5 GB space.最好将我们的 JVM 堆大小增加到 1.5 GB,同时仍保留 Berkeley DB 的 2.5 GB 空间。 Is there any way to access more than 4 GB RAM/heap in a 32-bit JVM ?有没有办法在 32 位 JVM 中访问超过 4 GB 的 RAM/堆? I've considering the following solutions我正在考虑以下解决方案
1) use a JVM which does better GC -- this will give me marginal results -- I could get about 50-100 MB working memory 1) 使用 GC 性能更好的 JVM——这会给我带来边际结果——我可以获得大约 50-100 MB 的工作内存
2) something like memcached or "out of process ehcache " -- this can get me as much as the hardware allows with the overhead of IPC/serialization. 2)像memcached或“进程外ehcache”之类的东西——这可以让我得到尽可能多的硬件允许的IPC/序列化开销。

Are there other solutions to increasing an application's addressable memory ?是否有其他解决方案来增加应用程序的可寻址内存?

The solution should work on solaris 10 running sparc.该解决方案应该适用于运行 sparc 的 solaris 10。

* UPDATE : Because of using native shared libraries, right now, we're unable to switch to a 64-bit JVM even though the OS is 64-bit * *更新:由于使用本机共享库,现在,即使操作系统是 64 位,我们也无法切换到 64 位 JVM *

thank you,谢谢,

Are there other solutions to increasing an application's addressable memory ?是否有其他解决方案来增加应用程序的可寻址内存?

  1. Split single application in several processes with non-shared memory (not a threads; but processes).在具有非共享内存(不是线程;而是进程)的多个进程中拆分单个应用程序。 First process can run DB and second can run other part of the project.第一个进程可以运行数据库,第二个进程可以运行项目的其他部分。 You can use RMI or shared memory or sockets to communicate between processes.您可以使用 RMI 或共享内存或套接字在进程之间进行通信。
  2. Lower memory, reserved for OS.较低的内存,为操作系统保留。 Eg on x86-32 PAE allows OS to reserve a smaller than 1 GB of 4 GB virtual address space.例如,在 x86-32 PAE 上,操作系统可以保留小于 1 GB 的 4 GB 虚拟地址空间。 (eg "4GB / 4Gb split", supported on Oracle Linux ) (例如“4GB / 4Gb 拆分”,在Oracle Linux上支持)
  3. Put some data to the disk.将一些数据放入磁盘。 The disk can be a RAM-disk to better speed;磁盘可以是 RAM 磁盘以提高速度; or it can be real disk and OS will speed up access to files using "page cache".或者它可以是真正的磁盘,操作系统将使用“页面缓存”加速对文件的访问。

Also, every real SPARC (not ancient SuperSparc or poor-man LION) is 64-bit really.此外,每个真正的 SPARC(不是古老的 SuperSparc 或穷人 LION)都是 64 位的。 So, it can be easier to switch to 64-bit version of OS.因此,切换到 64 位版本的操作系统会更容易。 I don't know about Solaris, but in linux there is possible to run 32-bit applications on top of 64-bit OS.我不了解 Solaris,但在 linux 中,可以在 64 位操作系统之上运行 32 位应用程序。 And 64bit OS will allow you to run 64-bit JVM. 64 位操作系统将允许您运行 64 位 JVM。

UPDATE: There are ramdisks in Solaris http://wikis.sun.com/display/BigAdmin/Talking+about+RAM+disks+in+the+Solaris+OS and I think you should try them for storing database (or temporary files of DB).更新:Solaris http://wikis.sun.com/display/BigAdmin/Talking+about+RAM+disks+in+the+Solaris+OS 中有 ramdisks,我认为您应该尝试使用它们来存储数据库(或临时文件数据库)。 There will be no extra serialization/IPC like in case (1);不会像情况 (1) 那样有额外的序列化/IPC; only extra read/write or mmap/munmap.只有额外的读/写或 mmap/munmap。 But Ramdisk is order faster than SSD and 3-4 orders faster than HDD.但是 Ramdisk 比 SSD 快,比 HDD 快 3-4 个数量级。

32-bit programs are incapable of handling more than 4GB of memory addresses. 32 位程序无法处理超过 4GB 的内存地址。 They just don't have enough bits to represent more memory.他们只是没有足够的位来表示更多的内存。

2^32 = 4 294 967 296 2^32 = 4 294 967 296

Your best bet would be to upgrade to a 64-bit JRE.最好的办法是升级到 64 位 JRE。

I suggest you run your 32-bit shared native libraries in a 32-bit JVM and run everything else in a 64-bit JVM.我建议您在 32 位 JVM 中运行 32 位共享本机库,并在 64 位 JVM 中运行其他所有内容。 You can have the 64-bit JVM call the 32-bit JVM to do whatever it does.您可以让 64 位 JVM 调用 32 位 JVM 来完成它所做的任何事情。 I assume the bulk of your data/memory requirement can be moved to a 64-bit JVM.我假设您的大部分数据/内存需求可以移至 64 位 JVM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM