0

I wrote a memory sensitive cache using soft references.

At first it worked well, but after a few days, memory pressure went high, then suddenly dropped.

Well, this is expected, I want to the cache to hold data as long as possible but not so long to cause out-of-memory. Kind of graceful degradation.

But from then, it didn't work so well. I find somehow it has become dropping data more aggressively.

The question is, does the JVM somehow tune itself adaptively and decides to drop SoftReference more aggressively?

ntysdd
  • 1,206
  • 2
  • 9
  • 19
  • I would say it's precise behaviour shouldn't be relied upon as different versions at different times can behave differently. One approach I take is to cache data off heap so it's isolated from the momentary behaviour of the application. – Peter Lawrey Oct 15 '18 at 06:29
  • @PeterLawrey Well, I did write an off-heap version (in fact it was designed from the beginning in a way that I could easily change it into an off-heap version). I am just curious. I don't understand why there seems a "phase change". – ntysdd Oct 15 '18 at 09:05

0 Answers0