# Optimal Page Replacement Algorithm - If more than one frame will not be used again, which one gets replaced?

This may not make a difference in the end, but not knowing is driving me insane. When using the Optimal algorithm for page replacement, if you need to put something new into a frame and you have more than one frame that will not be used again, how does it prioritize which one to replace? In other words, if you have three frames and you enter in 1, 1, 2, 3, and neither 1 or 2 ever appears again, which one gets bumped when you try to put in 4?

Does it go by FIFO and kick out 1, does it go by most used and kick out 2 or does it go by least recently used and kick out 1?

• Do you know 1 and 2 will never be used again? How do you obtain that knowledge? In general, there is no optimal page replacement algorithm because you want to drop those with the smallest probability of beeing used in the future, and in general, one cannot obtain knowledge about the future from looking at the past. Mar 6 '16 at 21:43
• I know that the optimal algorithm is impossible in practice, but I'm referring to the theoretical optimal that's taught in class. So in this case, we're imagining that it is possible to know the future and what's coming. This is a purely what-if question Mar 6 '16 at 22:01