New York CNN — It wasn’t long ago that China was by far the largest and most profitable market for General Motors. While the company was hemorrhaging money in North America and Europe, and hurtling towards bankruptcy and a bailout, sales and profits from China allowed it to keep the lights on.

Now the opposite is true. GM is making record profits at home, but it’s losing enough money in China that there are questions about how much longer it can stay. At the same time, Chinese automakers have flooded their home market with exactly the sort of desirable electric vehicles that Chinese buyers want and American automakers once dismissed.

The result has been catastrophic for foreign automakers in China.

GM’s Chinese sales are down 19% over the first nine months of the year, and it has lost $347 million on its Chinese joint ventures over the same period. Earlier this month, it announced its net income would be reduced by more than $5 billion due to the problems in China.

About half of that reflects the cost to restructure — and likely shrink — its operations there. The other half is a reflection that the value of its Chinese operations was no longer justified by today’s economic reality.

“You can look back 15, 20 years to when GM’s China operations was its life preserver. It certainly isn’t now. It’s a money pit,” said Jeff Schuster, global vice president of automotive research at research firm GlobalData. “Every international brand is suffering in China.”

While GM has yet to announce the details of its restructuring in China, Schuster and other experts said most Western automakers, including GM, are looking at how long they can stay in the world’s largest car market.