A 10 GB cache is not something you should do on the heap. Use ByteBuffers for caching. Building an object does not have to be expensive. Thus, the GC is not involved, and you yourself can manage everything.
For example, if you implement the page cache in the Java database management system, you would not create objects for it, but would use byte buffers or managed byte buffers or the best byte buffers. You can learn more about these three here .
If you process more and then say a million objects at a time, you will see that the proportion of GC time is increasing. I saw situations when we managed to create a huge number of nodes for data processing, and it was very slow. Then we switched to the direct byte buffer scheme and even used some additional technique in which we could store more data (objects cost 24 bytes, at least each) and stopped thinking about objects in the first place. As a result, we processed data, not objects. This has increased performance many times, and we can process much more data than we expected.
After that, we noticed that all this corresponds to the database and itβs good, and thatβs exactly where we put everything together.
So check out what direct buffers can do for you.
source share