where memory is allocate outside of Java heap. gc
2012-06-08 13:27
295 查看
7 down vote favorite 2 share [g+] share [fb] share [tw] | JDK provides abillity to allocate so-called direct ByteBuffers, where memory is allocate outside of Java heap. This can be beneficial since this memory is not touched by garbage collector, and as such does not contribute to GC overhead: this is a very useful for property for long-living things like caches. However, there is one critical problem with existing implementation: underlying memory is only allocated asynchronously when the owning ByteBuffer is garbage-collected; there is no way to force early deallocation. This can be problematic since GC cycle itself is not influenced by handling of ByteBuffers, and given that ByteBuffers are likely to reside in Old Generation memory area, it is possible that GC is called hours after ByteBuffer is no longer in use. But in theory it should be possible to use sun.misc.Unsafemethods (freeMemory, allocateMemory) directly: this is what JDK itself uses for allocating/deallocating native memory. Looking at code, one potential concern I see is possibility of double-freeing of memory -- so I would want to make sure that state would be properly cleaned. Can anyone point me to code that does this? Ideally would want to use this instead of JNA. NOTE: I saw this question which is sort of related. Looks like the answers pointed out are good way to go: here is code example from Elastic Search that uses the idea. Thanks everyon! |
相关文章推荐
- OutOfMemoryError: Java heap space和GC overhead limit exceeded在Ant的Build.xml中的通用解决方式
- OutOfMemoryError: Java heap space和GC overhead limit exceeded在Ant的Build.xml中的通用解决方案
- java heap space 问题 java.lang.OutOfMemoryError: ChunkPool::allocate
- eclipse启动项目报出jvm内存溢出异常解决办法java.lang.OutOfMemoryError: Java heap space
- Caused by: java.lang.OutOfMemoryError: Java heap space
- eclipse内存溢出报错:java.lang.OutOfMemoryError:Java heap space
- IDEA运行spark MLlib程序遇到java.lang.OutOfMemoryError:GC overhead limit exceeded
- java.lang.OutOfMemoryError: Java heap space
- java.lang.OutOfMemoryError: Java heap space解决方法
- Android Studio编译报错“java.lang.OutOfMemoryError: GC overhead limit exceeded”
- tomcat 配置 OutOfMemoryError: Java heap space OutOfMemoryError: PermGen space OutOfMemoryError: unable
- 访问数据库数据过大:java.lang.OutOfMemoryError: Java heap space :设置jvm虚拟机heap大小
- 【未解决】Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
- Java # java.lang.OutOfMemoryError: requested 32744 bytes for ChunkPool::allocate. Out of swap space?
- Myeclipse java.lang.OutOfMemoryError: Java heap space
- 内存不足 java.lang.OutOfMemoryError: Java heap space
- eclipse内存溢出报错:java.lang.OutOfMemoryError:Java heap space
- idea 项目启动报错解决,java.lang.OutOfMemoryError:Java heap space
- java.lang.OutOfMemoryError:Java heap space问题
- java.lang.OutOfMemoryError: GC overhead limit exceeded 问题分析和解决