Since 1994 Tracey Aldridge has been arrested 100 times, jailed 27 times for more than 1,000 days and spent a total of eight years in prison. Most of her arrests have been for trivia: trespassing, prostitution, drugs, disorderly conduct, petty theft or drinking in public, all typical of the mentally ill. Ms Aldridge is so impaired that one jail needed special arm coverings for her, like full-length oven gloves, to prevent her from ripping her veins out with her teeth. More recently, in prison, Ms Aldridge ate her protective gauntlets.

Thomas Dart, the sheriff of Cook County jail, knows Ms Aldridge will end up back in his cells soon because there is nowhere else for her to go. She is sentenced, like so many seriously mentally ill people in America, to rotate in and out of correctional facilities until she dies. Prisons and jails are the main mental-health facilities in the country, something Sheriff Dart describes as an "abomination". He is also angry about how fiscally reckless it is. At only 42, Ms Aldridge has already cost taxpayers $719,436 for her arrests and incarcerations.

For the mentally ill hospitalization rates go down and imprisonment rates go up

She is not alone. Depending on how you measure it, Sheriff Dart's jail is either the largest, or second-largest, mental-health institution in America. On any given day in Cook County jail one building is home to between 2,000 and 2,500 people with diagnosed mental illnesses. Each night's stay costs at least $190. Costs escalate when medical care is included. The Lamp Community, a non-profit working for the mentally ill in Los Angeles, says the desperate cycle of emergency-room visits and stints in jail can exceed $100,000 a year for each homeless person. Permanent supportive housing costs only $16,000.

The history of this quiet disaster can be traced back to the 1960s, when John Kennedy decided to treat more of the mentally ill in the community and a new drug called thorazine promised to help. Over the next decade, however, new centres did not arrive and thorazine was not as good as everyone hoped. Moreover, there was a rise in legal actions against state facilities.

Pete Earley, a journalist and author of a book on the American mental-health system, says that in one year in California 19,000 beds were cut. "There was no place for anyone to go, they were literally thrown on to the street," he says. Matters deteriorated in the 1980s, when large cuts were made to housing programs. Funds for the mentally ill remain a soft target.

Indeed, these days it is very rare for people to be put in a mental-health institution unless they are a danger to themselves or others. Even when they are held in a hospital, they are unlikely to stay long enough for any course of drugs to stabilize them. If someone decides he wants to walk around naked, or cannot give his name to a police officer, the likelihood is that he will end up in jail. Sheriff Dart, whose job is only to keep people safe while they await trial, says they should be treated better. People should not be pushed out on the street on their release day with "a baggie of drugs". Instead, he is discharging them with videos to help them adjust and counselling about the different services they may be able to use.

He is most excited, though, about a small pot of funding he has found which might divert a few of the mentally ill away from his jail. New arrivals now have an interview, and evidence of any brain disorder is passed to the public defender (a lawyer for those who cannot afford one), who is then able to plead for an alternative to jail. With some philanthropic help from a local businessman, Sheriff Dart has managed to get about a dozen people into a secure former nursing home where he monitors them with an ankle bracelet.

Carla Clark thinks this works well. She is the mother of a young woman, Melissa, who had a psychotic breakdown and who looked certain to be heading into the criminal-justice system. Melissa's problems started when it appeared she was taking something without paying at Wholefoods Market; but when two security guards came after her and she thought they were attacking her, she fought back. This led to a felony charge for robbery.

Her mother believes Melissa needs to be somewhere secure, so much so that she refused to bail out her daughter from jail because she was not taking her tablets. But now Sheriff Dart has found the girl a place in a home, things are much better. Melissa is taking her pills, and there is even a bit of group therapy. "Asylum", says Mrs Clark, "means safe place. What is so bad with that?"