Barney Panofsky (Paul Giamatti) is a Montreal-based television producer, who begins to reflect on his life and three failed marriages after a retired police detective (Mark Addy), who never stopped believing that Barney got away with the supposed murder of Barney's friend Boogie (Scott Speedman), publishes a scandalous book about him:
Barney married his first wife Clara (Rachelle Lefevre) after he finds out she is carrying his child. When she miscarries and Barney finds out the baby was not his, he leaves her. A few days later, Barney finds out that Boogie forgot to give him an apologetic note from Clara and when he returns to the apartment, he finds out that she killed herself when he never showed.
Barney marries "The Second Mrs. P" (Minnie Driver) after being introduced to her by his uncle. However at the wedding reception he meets, and falls in love with, Miriam (Rosamund Pike). He finds a reason for a divorce when he finds his wife in bed with Boogie, who was at Barney's lakeside cabin recovering from a drinking binge. Barney wants Boogie to testify for the divorce and this results in a drunken confrontation which ends with a gun going off and Boogie falling into the water. Boogie is never seen again (nor is his body found), which leads to the suspicion by the detective that Barney shot Boogie in a jealous rage.
Barney and Miriam get married and have a happy life and two children, even though some problems surface over Barney's supposed apathy towards Miriam's career ambitions and Barney's jealousy involving Miriam's friendship with Blair (Bruce Greenwood). One week Miriam decides to go off alone to visit their son in college. Barney becomes alone without her and makes the drastic choice of purchasing a burial plot, based on advise given by Barney's father (Dustin Hoffman) shortly before he died, so he can be confident that he are Miriam would be together forever. However, Barney later makes the mistake of having a one night stand with a women he met in a bar. After Barney confesses to Miriam, she leaves him and later marries Blair.
Back in the present, Barney finds out that he is starting to suffer from dementia and freaks out when he realizes that he can't remember Miriam's number. Miriam later meets him for lunch and Barney disapeers after she steps away for moment. She later finds him at the reception hall where they met and she finds out that his dementia has progressed to the point that he believes they are still married.
Barney's kid's are preparing his will when the news comes on saying that Boogie's body has been found after 30 years and looked like he was either severely beaten or dropped from a great height. Barney is nearly entirely gone by this point and he is sitting in a chair watching planes scoop water from the lake to dump on forest fires (which is likely how Boogie died). Barney dies shortly thereafter and Miriam visits his grave and it is revealed that she decided to keep the dual plot he got for them.
Thanks Sean K!