* Toshiba logs best-ever profit for its second quarter
* Nearly all the profit comes from its memory chip unit
* Flags potential $1.8 bln charge for LNG contract
* Says may have to withdraw from some loss-making operations
* Steps up capital investment in chip business (Adds potential retreat from some units, possible LNG charge)
TOKYO, Nov 9 (Reuters) - Japan's Toshiba Corp reported a 76 percent jump in second-quarter operating profit on Thursday, driven almost entirely by a strong performance from its memory chip unit which it recently agreed to sell for $18 billion.
The robust results on the back of soaring demand for chips used in smartphones and data centre servers underscore the difficulty Toshiba will face in generating substantial earnings once the unit - the world's No. 2 producer of NAND flash memory semiconductors - is sold.
Toshiba, desperate for funds to cover liabilities arising from it U.S. nuclear unit Westinghouse, agreed in late September to sell Toshiba Memory to a group led by Bain Capital, although under the deal it plans to repurchase 40 percent of the business.
Operating profit for July-September jumped to 135 billion yen ($1.2 billion), its best-ever result for a second quarter and beating a consensus estimate of 125 billion yen. Its chips and devices division accounted for 97 percent of that profit.
"We are aware that the proportion of the memory chip business in our overall profit is extremely high," Chief Finiancial Officer Masayoshi Hirata told an earnings briefing.
But he added that earnings from the conglomerate's energy and social infrastructure businesses were expected to improve as the company "has tightened risk control over the past year to focus on profits instead of scale."
Hirata also said Toshiba may look at completely withdrawing from loss-making operations that have already been scaled back such as its TV and personal computer businesses.
The struggling conglomerate, which has spent most of the past year in financial crisis, still faces a slew of risks including the likelihood that the sale of the chip unit may not close before the end of the financial year in March as regulatory reviews usually take at least six months.
If it doesn't get the deal done in time, it could end the year in negative net worth for a second year in a row, putting pressure on the Tokyo Stock Exchange to delist it.
Hirata stressed, however, that Toshiba was making preparations in case the deal did not close by end-March, saying it had "launched a working group to consider various measures" to raise capital.
The deal also faces legal challenges from estranged business partner Western Digital, which argues no deal can proceed without its consent.
Another key concern for Toshiba investors has been its 20-year contract to buy liquefied natural gas from Freeport LNG in Texas, a deal it struck as part of a plan to sweeten sales of turbines for power plants.
Amid a plunge in Asian gas prices, it must find buyers for the LNG or pay a fixed gas processing fee to Freeport of about $370 million per year for the life of the contract, which begins in 2019.
Hirata said that Toshiba could be hit with a charge of 200 billion yen ($1.8 billion) in relation to the contract if oil prices stay at current levels. While that is quite a big hit, it is much less than some analysts' speculation of billions of dollars in charges if no buyers are found.
Toshiba maintained its full-year operating profit forecast of 430 billion yen, of which 419.4 billion yen would come from memory chips.
As flagged last month, the company said it expects an annual net loss of 110 billion yen due to taxes related to the sale of the memory chip unit.
That does not reflect expected gains from the 2 trillion yen sale as the deal has yet to receive regulatory approval.
Toshiba also said it would boost investment in the chip business this financial year to 600 billion yen from a previous plan of 400 billion yen, mainly to speed up the installation of a memory chip production line.
The global chip market boom has boosted demand for chip-producing equipment to the extent that equipment manufacturers are telling Toshiba to book orders early or will not be able to get the equipment in time, Hirata said. ($1 = 113.5400 yen) (Reporting by Makiko Yamazaki; Editing by Edwina Gibbs)