With knees, there is a good number of research on relationship between weight gain and worsening of knee issues.
If there is no obvious causative trauma or injury, muscle weakness of your quadriceps and hamstring ratio (mismatch), hip muscle tightness and gluteal strength deficits are some points to look at. If you spend more time weight bearing, foot mechanics (stiffness of mid foot and hind foot) is important too.
We cant diagnose unless we get some idea of where the swelling is?.... front, sides or even behind the knee.
Next Steps
If weight is an issue consult a dietician for a good diet control. This along with exercise prescribed by a physiotherapist is a good combination for weightloss.
Health Tips
if the front of the knee is swollen, ice helps very often. wrapped in a towel for 15 mins, 3 times a day.