merge r908391 from trunk: avoid excessive and short memory allocations, check for allocation failures
Changed paths: