研究消除堆空间问题?
我们正在构建一个平台,据说可以加载任何 jar 文件并运行统计模型。我现在面临的问题是,某些模型运行太大,无法适应我们的平台,导致堆内存不足错误。我知道已经对此进行了研究,但我再也找不到它们了。本质上,谷歌应用程序引擎是如何做到这一点的?有人听说过基于磁盘的堆空间吗?
We are putting together a platform that can supposedly load any jar file and run statistical models. The issue im facing right now is that some models run too big to fit on our platform causing heap out of memory errors. I know there has been research done on this but I cant find them anymore. In essence, how does google app engine do this? Has anybody heard of any disk based heap space?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我假设您已经尽可能地扩展了堆(考虑到物理内存、处理器架构、JVM 和操作系统的限制)。
除此之外,答案是据我所知,没有 JVM 实现基于磁盘的堆空间。然而,这并不是一个完全荒谬的想法。曾经有一个学者社区(大部分)致力于“正交持久性”问题,其中对象在内存和持久性存储之间透明地迁移。不幸的是,有一些基本问题使得这项技术......变得困难。 (例如,垃圾收集持久存储、获得多线程应用程序逻辑一致的检查点以及处理代码更改。)无论如何,结果是该研究领域已经安静下来。
I assume that you've already expanded your heap as much as is realistically possible (given the constraints of your physical memory, processor architecture, JVM and OS).
Beyond, that the answer is that no JVMs that I'm aware of implement disk based heap space. However, it is not a totally ludicrous idea. There once was a community of academics (mostly) working on the problem of "orthogonal persistence" where objects migrate transparently between memory and a persistent store. Unfortunately, there were some fundamental issues that made this technology ... hard. (For instance, garbage collecting the persistent store, getting logically consistent checkpoints with multi-threaded applications, and dealing with code change.) Anyway, the upshot is that field of research has gone quiet.
基于磁盘的堆空间是微不足道的 - 它通常称为虚拟内存,而将数据从磁盘移动到内存并返回的过程称为交换。过去 3 年设计的任何操作系统都可以做到这一点。它不仅适用于堆,还适用于堆栈、程序内存本身等。尽管它相当慢,而且对于现代内存来说,价格通常是不必要的。
Disk based heap space is trivial - it's commonly called Virtual memory, and the process of moving data from disk to meory and back is known as swapping. Any OS designed in the last 3 decades can do it. It doesn't only work for the heap, but also for stacks, program memory itself, etc. It is quite slow though, and with modern memory prices often unnecessary.
您可以使用命令行开关来增加堆空间(通常最多 2GB)。
如果这还不够,那么您需要仔细调整应用程序的内存使用情况,这将需要有关其设计的更多信息。
You can use command line switches to increase heap space (generally up to 2GB).
If thats not enough then you'd need to carefully tune your apps memory usage, which would require more info regarding its design.
您可以使用这些参数来指定堆大小
java -Xms1024m -Xmx2048m
第一个是初始大小,第二个是最大大小。如果没有 RAM 来支持这个堆大小,那么操作系统将自动进行分页/交换来适应这个内存大小。当然,这显然会慢一些。
You can use these parameters for specifying the heap size
java -Xms1024m -Xmx2048m
The first one is the initial size and the second one is the maximum size. If there is no RAM to support this heap size, then the OS will automatically do pagination/swaps to accommodate this memory size. Of course, that would obviously be slower.