Cramping during a marathon is often the result of sodium depletion. Exercising more than 3 hours puts you at risk, not only for muscle cramping, but other serious problems too. Using table salt before any long runs can help with preventing leg cramps. Sport drinks or gel packs also contain a sodium mix. Carrying a salty snack, like pretzels, can help prevent cramping muscles.