Mattress Firm, the largest U.S. mattress retailer, is considering a potential bankruptcy filing as it seeks ways to get out of costly store leases and shut some of its 3,000 locations that are losing money, people familiar with the matter said.

Mattress Firm's deliberations offer the latest example of a U.S. brick-and-mortar retailer struggling financially amid competition from e-commerce firms such as Amazon.

Mattress Firm's South African parent, Steinhoff International Holdings, acquired Mattress Firm for $3.8 billion in 2016. Mattress Firm acquired the parent company of arch rival Sleepy's in 2016 for $780 million and then rebranded the stores.

The company has been working on a deal to restructure the debt of some subsidiaries with its creditors, following an accounting scandal. Creditors agreed last month to hold off on their debt claims for three years.

Sources familiar with the negotiations, who requested not to be identified because the plans are private, cautioned that Mattress Firm has not made any final decisions and its plans could change.

Many retailers pursue bankruptcy to reject leases, a move to slim their store count, cut their costs and reorganize to continue their business.

Representatives for Mattress Firm and AlixPartners declined to comment. Steinhoff did not respond to requests for comment.