Major knee problem

One Sunday AM I was out at the barn feeding, on foot. All of a sudden I could hardly just stand, bought went to my knees!!! I finally held my leg stiff and got myself back to the house. That 200ft seemed like 5 mles!!
I was a mess for hours. Went to doc next day, and he jus matterly of fact, says, a piece of cartlidge came loose and was just sorta floating around!! That was 4- years ago. Never happened to that extent since, but sometimes it will get to feeling like it is about to. If I squat or move odd, I an feel a problem ready to occur! I just hope I never need a joint replaced.