From amoebas engulfing one another to polar bears eating cubs, cannibalism is all over the natural world. But it’s a risky way to get food. Animals of the same species tend to have similar natural defenses and can easily share diseases. And eating one’s own offspring typically undermines genetic success. So what pushes some animals over the edge?

“Almost all predators express cannibalism when conditions get grim enough,” says Jay Rosenheim, an entomologist at the University of California, Davis. Some desperate herbivores do, too, he adds. After seeing predatory big-eyed bugs in California cotton fields begin gobbling up their own eggs despite a plethora of available prey, Rosenheim decided to investigate what motivates animals to become cannibals.

“The density of the population is often the key factor that throws that switch,” Rosenheim says. For a study in Ecology, his team synthesized more than three decades of published research to construct a mathematical model coupling such density to cannibalism.

“It seems so silly, but really, density dependence hasn’t been taken into account in a ton of modeling,” says Chloe Fouilloux, a researcher at the University of Jyväskylä in Finland, who was not involved in the work but studies cannibalistic frogs. Although some other models include density as a small component, this one focuses primarily on density-related variables such as the frequency of animals encountering one another and the likelihood of a meeting resulting in an attack.

The researchers also catalogued specific ways population density can induce cannibalism. Strained local resources are, unsurprisingly, a key factor: “Hunger is probably the closest thing to a universal or near-universal mediator” of cannibalism, Rosenheim says. The study highlights research suggesting that hunger makes particular neurohormones spike, encouraging aggression—and potentially cannibalistic behavior.

“I was excited to hear about how they are including more recent work on the [physiological] mechanisms underlying cannibalism,” Fouilloux says.

Disease spread, spurred by dense populations, can play a role in cannibalistic action as well. A sick animal might become hungry enough to eat its kin. Or a healthy individual could devour sick neighbors, taking advantage of their weakened state. “The interactions of density and disease and cannibalism are really, really complicated,” Rosenheim says, adding that the research area is ripe for discovery.

For some animals, the arrival of more of their own kind can trigger cannibalism despite an abundance of other food. This is the case with female big-eyed bugs; when it gets crowded, they start to behave as if their eggs might be from other females. By anchoring the model in real biological conditions such as food scarcity, disease risk and increasing chances of an encounter, Fouilloux says, the researchers showed that density is “this amazing regulating factor that helps explain and contextualize the role of cannibalism in stabilizing population dynamics.”