Building materials maker Owens Corning posted a quarterly profit that beat analysts' expectations, helped by lower costs, sending its shares up as much as 6 percent.

For the remainder of 2009, the company expects demand in building materials business, which includes roofing and insulation segments, to be affected by weakness in the U.S. housing industry.

Performance in roofing business, which is about 40 percent of total sales, is expected to more than offset weakness in insulation for the remainder of the year, it said.

The roofing industry has raised its price substantially and has been able to hang on to that price, despite slowing volumes, SunTrust Robinson Humphrey analyst Keith Hughes said by phone.

Owens Corning increased prices last year to due to a rise in asphalt costs. However, the price of asphalt came down later.

Within the roofing business, Owens Corning makes and sells residential roofing shingles and oxidized asphalt materials used in residential and commercial construction.

Hughes said, however, the industry will need to lower production rates due to falling volumes and that will push roofing margins down in the near term, particularly while going into the winter months.

For its composites business, which accounts for about 34 percent of total sales, Owens Corning expects demand to generally continue to trend upward as global industrial demand improves.

That business has a very diverse end-user market and I think it is going to post the biggest positive surprises for the next couple of quarters, said Hughes, who has a neutral rating on the shares of Owens Corning.

The company also raised its 2009 free cash flow outlook to about $300 million, up from its recently raised view of $250 million.

For the third quarter, the company reported earnings of $80 million, or 63 cents a share, compared with a loss of $807 million, or $6.35 a share in the year-ago period.

Net sales fell 17 percent to $1.34 billion.

Gross margin as a percentage of sales was 21 percent in the latest third quarter, compared with 17 percent in the same period a year ago. Marketing and administrative expenses fell about 11 percent.

Owens Corning reported adjusted earnings of 61 cents a share for the quarter.

Analysts on average were expecting earnings of 39 cents a share, before items, on revenue of $1.30 billion, according to Thomson Reuters I/B/E/S.

Segment-wise, roofing sales fell 9 percent to $561 million, hurt by lower demand associated with storm activity and new residential construction.

Composites segment returned to profit due to cost-reduction actions and steadily improving demand, Owens said.

Shares of the company were up 3 percent at $22.93 in morning trade on the New York Stock Exchange. They touched a high of $23.64 earlier in the day.

(Reporting by Bijoy Koyitty in Bangalore; Editing by Maju Samuel, Anil D'Silva and Aradhana Aravindan)