mblodget wrote:I understand that nobody else but me can see those memories, but once he dies, will it merge with his "real" record ID that everyone can see? Or can I do it even if it doesn't happen automatically?

I would not expect it to happen automatically - at least not until enough time has passed that it's obvious that he's dead.

But if you merge it manually, I would expect the memories to be visible.

Have you searched the Wiki?
Try using a Google search by adding "site:tech.lds.org/wiki" to the search criteria.

mblodget wrote:If I attach memories to someone who is living (like my great-grandpa), what will happen when he dies?

Nothing happens when he dies. Your record for him is in your private space, and is not connected to his membership record (assuming he is a Church member), and so there can be no automatic change in your record when he dies.

mblodget wrote:I understand that nobody else but me can see those memories, but once he dies, will it merge with his "real" record ID that everyone can see? Or can I do it even if it doesn't happen automatically?

Once he dies, you can mark your private space copy of his record as deceased. Then you can merge it into the real record (his real record will have birth and death items recorded by "LDS Church Membership" and will have ordinances attached). When you do that, all memories attached to your copy of the record will be merged into the real record as well.

Everyone else who has a private record for that same individual will need to go through the same process. This is all explained in the FamilySearch Help Center article Understanding Private Spaces.