Is there any java memory structures that will automatically page data to disk?
Basically, I am caching a bunch of files in memory. The problem is, if I get too many files cached into memory I can run out of memory.
Is there any sort of java memory structure that will automatically page part of itself to disk?
For example, I would like to set a 2 mb limit the size of the files in memory. After that limit I would like some of the files to be written to di开发者_JAVA百科sk.
Is there any library that does this sort of thing?
Grae
"files in memory". Conventionally, in memory data is stored in some data structure like a HashMap or whatever, and referred to as a 'file' when its written to disc. You could code a data storage class which did this programmatically. I don't know of any library which did this. It would be pretty useful. In effect you would be implementing virtual memory.
This link will might help you :
http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html
EhCache is general purpose caching library for Java. One of the option is to have disk-backed cache, which overflows to file system. Seems to be exactly what you need.
精彩评论