Popping sound in knee can be due to injury to medial meniscus of the knee or to patella. Another possibility is the knee cap rubbing against the underlying cartilage of femur. Having said this, at times the noise has no pathology behind it.
The various causes of knee locking are torn medial meniscus, mis-aligned knee cap, osteoarthritis, knee arthritis, torn lateral meniscus, osteochondritis dissecans, recurrent patella dislocation, chondromalacia patella, knee alignment problem, knee fragment or knee cartilage disorder. Hence you may need X-rays and MRIs of the knee to find the exact cause. This needs an evaluation by either an orthopedics specialist or by a sports injury specialist. Take care!