@PascalDragon try except does work if I do not set ReturnNilIfGrowHeapFails to True, but I need to set it to True as I want to control the memory allocation. If I set ReturnNilIfGrowHeapFails to True, even with try except, it throws error on finalizing the array on end of function. Is this a correct behavior or a bug?
@ASerge, that is an interesting way, but is it not slow to allocation twice?