Is there utility program for Page replacement algorithm simulation in Java?
Java abstracts away the concrete memory management, so there should seldom be a need for this.
Think some more seconds. No, there is no such algorithm in the standart libraries.
If you mean 'Page replacement' as in virtual memory management, I cannot see there would be something like that. I mean the JVM does a lot of work to hide that from developers and provide a consistent memory model (with varying degrees of success).
Finally I developed-
Check out it
If you just want to experiment with different algorithms and learn how they work, then you may want to have a look at custard-cache -- this is an embryonic open-source implementation of some of the most common page replacement algorithms, along with an adapter for those algorithms to be used in JBoss Cache and a very small test suite to let you run different cache algorithms over our own sample data to judge hit ratio + effectiveness.
Now, a disclaimer: I wrote it this code. It was developed as an experimental exercise at my employer, where we were trying to maximise the efficacy of a cache and wanted to know if a different algorithm would help us. We didn't end up changing algorithms, but we figured someone else might have a use for it so open-sourced it. Nothing much has been done with it since but please take a look and see if it's useful.
Paging algorithms implemented are:
- Direct-mapped (associative)
- Adaptive Replacement Cache (and Fixed Replacement Cache)
- Multi-Queue Replacement
- Johnson and Shasha's 2Q algorithm
There are others I'd like to implement (the Clock family, LRU-K, CAR) but haven't got around to it.
Hope it's helpful!