Throw On Failure: ArrayAllocationBase

ArrayAllocationBase leaves the HeapBlock set to not throw if the allocation fails.


Hmmm good question. You’re right, seems to me that throwOnFailure should be true in this case. I’m a bit worried about changing this though as this would be quite a deep change. It could also have performance implications. Better wait until Jules is back from his holidays… sorry!

It’s quite an important point. Allocating an over-large array is a very likely scenario and one which the application could potentially fail gracefully from without cutting its own throat in the process.

What do you think the performance implications are? I can’t see it being a problem (one comparison and a jump when the array is resized/created), but maybe I’m missing something.

I wouldn’t be surprised if small arrays are constantly (re-)allocated in some code-bases of JUCE users - even in tight loops. Having the functions potentially throw may add a bit of code to their execution (stack unwiding etc.). I’m just guessing here - but I don’t want to do such a deep change without asking Jules.

Yeah - totally … interesting analysis I think :slight_smile: wish i had more time for C++ theory :slight_smile: