(Reuters) - Mattress Firm Inc, 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.

FILE PHOTO: A Mattress Firm store, a brand owned by Steinhoff, is shown in Encinitas, California, U.S., January 25, 2018. REUTERS/Mike Blake/File Photo

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.com Inc AMZN.O. Shares of Mattress Firm competitor Tempur Sealy International Inc TPX.N jumped on the news and ended trading on Monday up 5.2 percent at $52.64.

Mattress Firm's South African parent, Steinhoff International Holdings NV SNHJ.J, 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.

Steinhoff acquired Mattress Firm for $3.8 billion in 2016.

Both Houston-headquartered Mattress Firm and Steinhoff are working with consulting firm AlixPartners LLP, the two sources said this week. AlixPartners helps companies plan and execute turnaround strategies, and is often brought in to lay the ground for bankruptcy.

The sources, 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.

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

Filing for bankruptcy would allow Mattress Firm to clean up its real estate portfolio and improve cash flow and profitability, analysts at Piper Jaffray Companies PJC.N wrote in a research note last week.

Many retailers pursue bankruptcy to reject leases, a move to slim their store count, cut their costs and reorganize to continue their business. U.S. discount footwear retailer Payless ShoeSource Inc, for example, closed roughly 700 mall-based stores in bankruptcy last year, while children’s clothing shop Gymboree Corp closed about 300.

To be sure, some retailers shut huge swaths of their store base outside of bankruptcy. Bebe stores Inc BEBE.PK closed nearly all its retail locations without filing for bankruptcy last year, negotiating a deal with its landlords instead.

Mattress Firm lost Tempur Sealy International Inc TPX.N, the maker of popular mattress brand Tempur-Pedic, as a supplier last year, limiting its offerings. Mattress Firm secured a $225 million asset-backed revolving loan last year.

Steinhoff booked a $12 billion write-down earlier this year relating to accounting irregularities.

Steinhoff also owns discount chains Poundland in the United Kingdom and Ackermans in South Africa.

Mattress Firm acquired HMK Mattress Holdings LLC, the parent company of competitor Sleepy’s, in 2016 for $780 million and then rebranded the shops. Sleepy’s had over 1,050 stores on the U.S. East Coast and Illinois.