First of all, no matter how tempting it is to lay down and rest after having a meal, we should always resist! According to an article written by Brynne Chandler, sleeping right after meal makes it hard for our body to digest the last meal, especially if one has eaten too much. He emphasized that this may lead to problems ranging from indigestion to a possible risk of stroke.
Now if we are going to relate this to weight gain, I would like to point you to an article written by Frank Apodaca. He mentioned that the time of eating is not the ultimate culprit rather the kind of food we eat. This is further supported by another article, written by Juliette Steen, quoting dietitian Robert Clark that nighttime metabolic rate averages the same as during the day. Hence, if in case you are referring to a having a snack on top of the dinner, if for instance you are staying up late and you decided to grab a bag of chips, this will definitely increase you caloric intake, which will then result to weight gain.
So how long should we have to wait before going to bed? Apodaca recommends that we should stay up for at least two to four hours to give our body enough time to digest the food.
In case you want to read the articles mentioned, here are the details you may use to search for them:
Brynne Chandler - The Disadvantages of Sleeping Immediately After a Meal
Frank Apodaca - Is it Bad to Sleep After Eating?
Juliette Steen - Is Eating Before You Sleep Bad?