Jim Frederick, Time magazine journalist and author of the book “Black Hearts,” about the Iraq war. He died July 31 at age 42. (Photo by Peter Hapak for TIME)

Jim Frederick, a Time magazine editor and foreign correspondent who was the author of “Black Hearts,” a searing account of one of the most notorious atrocities by U.S. troops during the war in Iraq, died July 31 in Oakland, Calif. He was 42.

The cause was cardiac arrhythmia and arrest, his wife, Charlotte Greensit, said. He collapsed at a gym in Berkeley, Calif., and was transported to a hospital in Oakland.

Mr. Frederick held many high-profile jobs at Time, including Tokyo bureau chief, managing editor of Time.com and senior editor in London, in charge of the news weekly’s international coverage.

He was best known for his 2010 book, “Black Hearts: One Platoon’s Descent Into Madness in Iraq’s Triangle of Death,” which a reviewer for Britain’s Guardian newspaper hailed as “the best book by far about the Iraq war.”

Based on hundreds of interviews and on documents obtained through the Freedom of Information of Act, Mr. Frederick’s book provided a ground-level view of the life of a combat unit from the Army’s 101st Airborne Division in Iraq during 2005 and 2006.

He focused on Bravo Company, an often-undermanned unit seeking to bring order to a dangerous region south of Baghdad called the Triangle of Death.

“Within Bravo’s first ninety days in theater,” Mr. Frederick wrote, “all three of its platoon leaders, its first sergeant, a squad leader, and a team leader (in addition to several riflemen) had been wiped from the battlefield by death or injury.”

The soldiers were under the threat of constant attack, and “the feeling that death was certain was becoming pervasive.”

Mr. Frederick’s group portrait displays the panoply of human traits, from loyalty and courage to disaffection and horrifying depravity. The unit’s goals were not always clear, he wrote, leadership was lackluster, and the troops were stretched beyond their limits.

“They did not have enough men and resources to accomplish the task that was handed to them,” Mr. Frederick wrote. “They were asked to do the impossible, and the United States military tends to believe that it can do the impossible.”

Despite official prohibitions, drinking and drug use were rampant among the troops, as well as a widespread contempt for the Iraqi people, he reported.

“Isolated physically and with limited links to the outside world, Bravo soldiers frequently had no knowledge of how their efforts were fitting into the broader strategy of the war, let alone what that strategy might be,” Mr. Frederick wrote.

“I knew I was going to die,” one soldier told him, “it was just a matter of time, so I didn’t care.”

Order broke down completely in March 2006, when a group of drunk soldiers invaded an Iraqi home, raped a 14-year-old girl, then killed her, her parents and her younger sister. It took several months for the events to come to light. Five soldiers were later convicted in connection with the crimes or their attempted coverup.

Mr. Frederick retraced the steps leading to the attack, but he also highlighted a military structure that sent poorly trained troops to the front lines with only a vague idea of their mission.

“It was the feeling of isolation at all levels of command that caused what happened,” one sergeant told Mr. Frederick. “If people continue to treat this like a mysterious event that came out of nowhere, and don’t change how we lead soldiers, and we don’t honestly look at what caused this to happen, it’s going to happen again.”

James Durkin Frederick was born Nov. 22, 1971, in Lake Forest, Ill., and grew up in the Chicago suburb of Libertyville, Ill. His father was a business executive and his mother a clinical research nurse.

Mr. Frederick was a 1993 graduate of Columbia University and received an MBA from New York University in 2002. He held jobs at Men’s Journal and Working Woman magazines before joining Money magazine as a reporter in 1997. He went to Time as Tokyo bureau chief in 2002.

In 2008, he was the co-author of “The Reluctant Communist,” with Charles Robert Jenkins, a U.S. soldier who deserted his post in Korea in 1965, walked across the border and remained in North Korea for 40 years. The book has been optioned to a Hollywood film production company.

Mr. Frederick sometimes appeared as a commentator on television news programs or as a speaker at international conferences. After serving as editor of Time International, he left the company in 2013 and spent a year traveling around the world and writing a screenplay with his wife, Charlotte Greensit, a former Time journalist. They were planning to start a media consulting firm in San Francisco.

In addition to his wife of almost three years, Mr. Frederick’s survivors include his parents; a brother; and two sisters.

“Black Hearts” has been recognized as “a profoundly chilling study of military leadership gone bad, and bad leadership in combat makes for a disaster,” retired Army Lt. Col. Paul Christopher wrote in Military Review, an Army publication.

“What does an infantry rifle platoon do?” one sergeant told Mr. Frederick in his book. “It destroys. That’s what it’s trained to do. Now . . . let slip the leash, and it becomes something monstrous.”