The lonely death last month of a Marine Corps veteran supposedly on suicide watch in an overheated, unventilated Rikers Island isolation cell shocks the conscience — but it should surprise no one.

For five decades now, it has been the practice to deny asylum to many of America’s most vulnerable citizens — its publicly mentally ill. Certainly a case can be made that it was this shameful policy, as much as anything else, that killed Jerome Murdough — a 56-year-old vagrant being held on trespassing charges — in his Rikers cell.

It would be, however, a circumstantial case.

For Murdough was a complex character. Essentially living on the streets, with a robust drinking problem and profound psychiatric troubles, he’d been arrested in the stairwell of a Harlem housing project, charged with trespassing and then dispatched to Rikers when he couldn’t make $2,500 bail.

On Feb. 15, he was found dead in his stifling cell in a section of the jail reserved for the mentally ill — never mind that, having been deemed suicidal, he was to have been checked every 15 minutes.

“He basically baked to death,” a jail official told the Associated Press — a claim that has not been credibly refuted.

Nor likely will it be. Rikers Island is a troubled place.

On Monday, for example, US Attorney Preet Bharara charged a Rikers correction supervisor with deliberately ignoring the death throes of a prisoner who had swallowed a caustic cleaning solution in 2012.

Inmate-on-inmate violence is endemic there, and beatings of prisoners by guards chronic.

With 12,000 detainees on any given day, Rikers is dirty, noisy and seething with angry, resentful, often dangerous men (and not a few women) — most awaiting trial, and most more or less guilty as charged.

But while formal guilt is one thing, criminal intent can be quite another. The city estimates that 40 percent of Rikers detainees suffer from mental illness. Most appear harmless, at least to anyone other than themselves. But others are just rattlesnake dangerous when overtaken by their moods — and public safety, to say nothing of common sense, demands that they be isolated.

And so they are, never mind decades of custom and case law dictating that mental illness not be treated as common criminality — that restraint, when necessary, be rendered in the “least restrictive manner” possible.

Easier said than done.

From a police officer’s perspective, the distinction between a “decompensating” psychotic and someone who does violence for power, profit or out of sheer perversity can be academic. For the cop, Job One is to control the situation; the public defender, and the civil-liberties lawyers, can sort things out later.

But such sorting can be an imprecise process. One Justice Department study suggests that about half of the nation’s state prison inmates — and some 65 percent of those in local lockups — suffer from mental illnesses, with the vast majority receiving no treatment while behind bars.

Maybe those numbers are high. Well-intentioned academics are doing the counting, after all, and prison inmates are preternaturally good at telling the naïve and the impressionable just what they want to hear.

But it remains that in New York in the early ’80s — as the state emptied its mental hospitals in the name of “deinstitutionalization” — entire cellblocks in maximum-security prisons were given over to segregating inmates who clearly were insane, but who’d been arrested, charged and convicted as violent felons because police and prosecutors had no better way to deal with them.

Things have changed, of course. Laws have been refined; psychiatric medications are more effective; halfway houses and emergency shelters provide sanctuary that was absent early on.

Yet anyone with even rudimentary knowledge of how the system really works understands that prisons too often remain the repository of last resort for the mentally ill — especially those whose symptoms are ambiguous and whose motivations are unclear.

The benefit of the doubt usually goes, as it should, to public safety.

Thus it remains easy to fall through the cracks — partly because of that lack of clarity, and partly because it’s still so difficult to find alternatives to incarceration for those teetering on the edge, who need restraint but who are incapable of imposing it upon themselves.

Jerome Murdough appears to have been nobody’s idea of dangerous — just a profoundly troubled former Marine artilleryman whose once-promising life took him instead to Rikers Island. Fatally.

The city needs to clarify the circumstances of his death, to be sure. But doing so won’t solve the problem — of which Murdough was merely a symptom.

New York — indeed, America — remains shockingly bad at dealing with public mental illness. A full 50 years after the demise of the asylum, that’s just crazy.