fixed memory leak for non flash targets