"The Majestic" (2001) is a movie starring Jim Carrey, not Robert Downey Jr., about a screenwriter who loses his memory and ends up in a small town where he becomes the unlikely hero.
It's easy to mix them up, as both films feature a small town setting and a focus on a character with a troubled past.