The reference is to the bible story of the Gadarene swine in chapter 5 of the gospel of Mark. Jesus exorcised demons from a possessed man. The demons then entered a herd of pigs, which rushed off a cliff in a frenzy.
And forthwith Jesus gave them leave. And the unclean spirits went out, and entered into the swine: and the herd ran violently down a steep place into the sea, (they were about two thousand;) and were choked in the sea. (St James Bible).