“It’s a mental game in there,” Miller, now 46, said recently, still reflecting the anger and acting out that repeatedly got him sent to what prisoners call “the hole.” “You’re fighting with your own sanity, trying to keep yourself together.”

He was eventually vindicated by new DNA evidence and freed — but not before the time spent alone in a cell had taken its toll.

The use of segregation units — where roughly 500 of the state’s 11,000 prisoners are held in Massachusetts on any given day — has come under increased scrutiny over the last year, with state and federal court rulings limiting their use. State legislators have proposed regulating them further.

The Department of Correction defends what it calls special management units, saying they are needed to keep unruly inmates in order.

“We have to be realistic when we’re running these prisons … Segregation is a necessary tool in a prison environment,” said Luis S. Spencer, the department’s commissioner of correction.

The growing divide over their use in Massachusetts mirrors a national trend. Prisoner-rights advocates, legislators, and even corrections commissioners in other states are increasingly denouncing the use of solitary confinement, while others defend the practice as an essential part of prison management.

“There really is a seismic shift going on in both the public attitude and corrections practice,” said David Fathi, director of the American Civil Liberties Union’s National Prison Project, which has researched the effects of segregation. “I think there has been a growing awareness of the extremely damaging effects of solitary confinement.”

Massachusetts officials maintain that prisoners are kept in the units only as long as needed and that department staff check their records multiple times a week to determine whether it is time to return them to the larger prison population.

But the protocol is often contradicted by the department’s own data. Recent data compiled by the Prisoners’ Legal Services, a Massachusetts prisoners advocate group, show that inmates in some short-term units are being held far longer than initially intended.

Inmates at the units at the Souza-Baranowski Correctional Center in Shirley had been held an average of 139 days at one point in September 2012. One prisoner had been there for 662 days.

At MCI Cedar Junction in Walpole, inmates had been in the specialized management units an average 114 days, with one inmate having been there for 430 days.

A Globe review of one day in early March found that 492 of 619 segregation units in prisons across the state were filled. The department’s long-term disciplinary segregation unit in Walpole was at capacity, with 125 prisoners.

“We have to make sure people don’t stay any longer than they need to be, it shouldn’t be long-term, and there should be guidelines on what [an inmate] has to do to get out of there,” said Leslie Walker, of Prisoners’ Legal Services. “It’s literally lock them up and throw away the key — at a very expensive cost.”

The use of segregation is as old as the American judicial system. Though the units differ from one facility to the next, prisoners in a typical solitary confinement-like setting are locked in a cell for all but an hour a day; during that time they are allowed to exercise or shower.

Food is brought to them. They have a pad and pen, though on rare occasions they may have a radio or television. For the most part, they are by themselves.

In Massachusetts, prisoners can be sent to the units for a variety of reasons. In “administrative segregation,” inmates are held in the units until the department can determine a safe place for them.

Inmates involved in fights or other infractions can be sentenced to short-term “disciplinary segregation” for up to 15 days, though the sentence can be increased for multiple infractions.

Also, the department has a 125-bed Department Disciplinary Unit in Walpole, where prisoners can be sentenced to solitary confinement cells for up to 10 years for serious infractions. Miller was sent there for repeated fights with corrections officers.

State Senator James Eldridge, Democrat of Acton, who has two state prisons in his district, sponsored a bill recently that would significantly limit the use of solitary confinement to only the most necessary occasions.

The Department of Correction would then have to demonstrate the need for the continuing placement of the inmate in the unit and would have to offer structuring programs and mental health examinations. The inmate would have opportunities to challenge the segregation.

“There’s very little review of the prisoners put into solitary confinement, and we need proper oversight over what I believe is cruel and unusual punishment,” Eldridge said.

As recently as November, the courts have affirmed that segregation constitutes a punishment, even if an inmate was being placed there for his own protection. In that case, the Supreme Judicial Court upheld the rights of an inmate who had been in segregation for 10 months.

Even nationally, the US Bureau of Prisons agreed in February to conduct for the first time a comprehensive assessment of its use of solitary confinement, following a congressional hearing last year on the human rights and fiscal and public safety implications of the units.

“I think over the past year, there’s been a lot more scrutiny and discussion over, ‘is this the proper way to treat human beings,’ ” Eldridge said.

Prisoners with no history of mental illness can develop one in the units, government and academic studies have found. And prison officials are finding that the costs of running solitary confinement units are sometimes outpacing the associated benefits of their use.

Stuart Grassian, a Massachusetts-based psychiatrist who has conducted research on the units here and nationwide and who has testified at trials as an expert on prisoner segregation, said the lack of stimulation within the units can create or exacerbate a prisoner’s health problems, leading in some cases to delirium, which often goes untreated.

“You end up in a vicious cycle,” said Grassian. “What becomes very clear is solitary confinement is very, very toxic to anyone, and the people who end up there are typically the people who are least capable of tolerating it.”

Recognizing the effects of long-term segregation, a federal judge last year ordered the state Department of Correction to maintain alternatives to solitary confinement for inmates who were diagnosed with a certain classification of mental illness, part of a settlement the department reached with prisoner advocate groups following an alarming number of prisoner suicides.

By all accounts, the new units have been successful: New data show that since the 29 units were created, 82 percent of the inmates who were sent there did not engage in behavior necessitating the use of force following their release; 94 percent did not assault a staff member; 67 percent did not engage in a violent action toward another inmate; 30 percent incurred no disciplinary report. Those numbers reflect improvement over the behavior of inmates who did not go through the program.

“These are alternatives to segregation,” said Larry Weiner, the Department of Correction’s assistant deputy commissioner of clinical services. “We gauge what their mental health needs are, and we try to classify them according to their mental health needs.”

Beyond the 29 units, however, Massachusetts has been more reticent in creating similar programs for inmates who do not meet the mental illness threshold the state has set, even though the inmates may have underlying behavioral problems that have not been addressed.

Spencer, while maintaining that the segregation units remain an important tool, said he would explore other programs if state resources would allow.

A Globe review found that other states have been increasingly creating widespread alternatives to segregation, even for inmates who do not have a classified mental illness, by providing inmates with programs outside the cell to improve their behavior.

Mississippi, for instance, reduced the number of prisoners in segregation by 75 percent, resulting in a 50 percent reduction in violence. In Illinois, officials last year closed a super-maximum-security prison, saying it was needless and would save costs.

“You need to look at how people are getting into segregation,” said Joseph Ponte, commissioner of the Maine Department of Corrections and a former superintendent at the prison in Walpole who has been acclaimed for reforms in his department.

For inmates who have no history of mental illness, the Maine department works to resolve behavioral problems by offering enhanced education, job training, or even anger management programs — any alternative to housing prisoners in a cell for 23 days with no outside communication.

“We try to see if we can develop an individual treatment for the prisoner,” Ponte said, acknowledging that, for years, “You’d have an inmate in segregation for 30 months, on a basic write-up.”

Jose Bou, 37, of Springfield, a former prisoner, said he saw firsthand how a solitary confinement-like setting could be counterproductive. A decade ago, he was sent to a maximum-security prison because he was facing a lengthy sentence under mandatory guidelines for drug convictions, and he was placed in a cell for 21 hours a day.

“It was segregation, and isolation, a different world,” he said. “When they open those doors, that anxiety, you can cut it with a knife. It’s like a balloon that’s ready to pop.”

Later, he was housed in a minimum-security prison in Norfolk, where he was able to attend college classes and earn a degree. Today, he works as a youth counselor in Springfield.

“Had I not gone to Norfolk, who knows the type of person I would be in society,” he said.

Miller, who spent far more time in solitary confinement, including at the disciplinary unit in Walpole, said he was not so lucky.

He was not supposed to be in jail in the first place. At 23 years old, he was sentenced to 25 to 45 years for the rape of an Emerson College student in 1989. It was not until 2000 that DNA evidence confirmed his innocence and he was released.

He acknowledges he was angry, leading to repeated fights with corrections officers and other inmates that resulted in his segregation. But he never recovered, either, he said, and still suffers from anger and drug and alcohol abuse.

“I was a loner in there,” he said recently. “I wouldn’t say I’m better. People come out a different way, you’re not going to come out the same way. It’s just too much separation, seclusion, for anybody to have to bear.”