otrx: optimize memory usage when creating TRX image