Throw On Failure: ArrayAllocationBase


#1

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

Intentional?


#2

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!


#3

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.


#4

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.


#5

Yeah - totally … interesting analysis I think :slight_smile:


#6

https://stackoverflow.com/questions/1834405/do-potential-exceptions-carry-an-overhead wish i had more time for C++ theory :slight_smile: