Page replacement algorithm simulation in Java

Is there utility program for Page replacement algorithm simulation in Java?

-------------Problems Reply------------


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)
  • FIFO
  • LRU
  • LFU
  • 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!

Category:java Views:1 Time:2010-05-31

Related post

  • page replacement algorithm 2011-05-04

    What is the name for the page replacement algorithm for 2.6 linux kernel? --------------Solutions------------- Linux calls it the "Page Frame Reclaiming Algorithm". In my limited understanding, it's basically LRU with a bias towards non-dirty pages.

  • Can we obtain LRU (least recently used) page replacement algorithm in O(1)? 2012-04-11

    Can we obtain LRU (least recently used) page replacement algorithm in O(1) (i.e constant time)? Please give the algorithm if possible. --------------Solutions------------- A doubly-linked list can implement a LRU queue with O(1) operations. Used node

  • What is the page replacement algorithm used in windows7? 2012-01-26

    I am looking for the page replacement algorithm used in Windows 7? is it still FIFO or LRU? --------------Solutions------------- Hello Abdullah, The issue you have posted would be better suited on the Microsoft TechNet support forum. I would suggest

  • Which Type of Page Replacement Algorithms the Windows 7 is use ?? 2014-09-07

    Hi everybody, Every year we heard about something new that MICROSOFT manufacturing it, and every year we learned something new in MICROSOFT products. Since we have now the newest version of windows which is Windows 7, and as I am a computer science s

  • Performance replacement for String in Java 2010-01-20

    Anyone remembers the name of that opensource "project" that developed some nice replacement for String in java ? I know there is is one, just cant find it in google and dont remember the name. (i am not talking about StringBuilder) Thanks -----------

  • How to replace single quote in Java with Postgres? 2011-04-21

    How to replace single quote in Java with Postgres? select * from where id in ('<45646300.KDSFJJSKJSDF95'fdgdfgdfgd>', 'fdgdfgdg'); I always use params like select * from where id = ?; But in this case i have problem, where i have 'in' statement

  • Quicksort algorithm program in Java 2010-02-05

    I'm trying to implement QuickSort algorithm program in Java, but I'm getting incorrect answer. public class QuickSort { public static void main(String[] args){ int arr[]={12,34,22,64,34,33,23,64,33}; int i=0; int j=arr.length; while(i<j){ i=quickS

  • Page replace with RJS 2010-05-04

    I try to implement a vote feature in one of my rails projects. I use the following codes (in vote.rjs) to replace the page with a Partial template (_vote.rhtml). But when I click, the vote number can not be updated immediately. I have to refresh the

  • how do i pass a pass a arraylist from html page to a servlet in java? 2010-12-12

    how do i pass a pass a arraylist from html page to a servlet in java? --------------Solutions------------- A HTML page doesn't have any notion of ArrayLists. HTML is a markup language which consists of tags. If you want to send information from the c

  • Physics Simulations in Java 2010-12-15

    Are there any good books that teach how to make simple physics simulations in Java? --------------Solutions------------- Yes, I recommend you this one: Also you can check a lot

  • Is there a way to automatically replace a pattern in .java file on build-time? 2010-12-23

    I want to be able to replace specific pattern in .java files on build time. In fact, I just want to replace certain String value to represent build time. (And I also want to leave original source file intact). Is there a way to do it easily (apart fr

  • How search engine, say Google's page ranking algorithm work across distributed/multiple machines? 2011-09-19

    I am new to distributed computing but was wondering how page ranking algorithm works across multiple machines. Like When do they decide data should be replicated (if needed at all), If data is not copied, do they ask serves at other places to give th

  • Dynamic Page/Replacing Content with a twist (wordpress) 2011-12-04

    I'm wondering how hard it would be to dynamically replace content in a wordpress site through the use of JQuery. This is the article I'm going off of: My basic idea was to change the elements

  • How to get a web page's source code from Java 2011-12-23

    I just want to retrieve any web page's source code from Java. I found lots of solutions so far, but I couldn't find any code that works for all the links below:

  • Dynamic page/replace content and jQuery conflict 2011-12-29

    I've read several posts on SO on similar subjects, but was unable to dissect and get my code to function the way I want it too. I'm creating an app where page content is changed and replaced dynamically. This is the link to the plug-in I used (yes, I

  • Insertion sort algorithm flaw in Java code 2012-01-14

    So I am going through some of the common sorting algorithms and have written this: Code: public void insertionSort() { int key; int i; for ( int j = 1; j < this.a.length; j++ ) { key = a[j]; i = j; while ( i > 0 && a[i-1] > key ) { a

  • Is it possible for a FIFO page-replacement strategy to outperform LRU? 2012-03-05

    As part of my operating systems homework, I was asked to compare the number of page faults produced by first-in-first-out and least-recently-used page-replacement strategies for a given sequence of page accesses. Perplexingly, it appears that FIFO pr

  • virtual memory page replacement 2012-03-19

    It is known that some pages need to be replaced in the demand of paging when all frames are full.However, pages can be used as text, rodata, data, which are all called in from disk I/O, but pages such stack, heap of a program are allocated in the mem

  • Trying to view a Web page in Windows 8 and Java applets do not appear, only a red x?__ 2013-07-23

    Trying to view a Web page in Windows 8 and Java applets do not appear, only a red x? --------------Solutions------------- Tools>Internet Options - Security tab, click the "Reset all zones to default level". Perhaps the page you are looking at is i

Copyright (C), All Rights Reserved.

processed in 0.185 (s). 11 q(s)