JUCE
JUCE copied to clipboard
juce_core: Fix infinite allocation loop in AllocationHooks
AllocationHooks has a ListenerList member variable which was recently updated to allocate on instantiation of its internal listeners list:
const SharedListeners listeners = std::make_shared<ArrayType>();
Call to std::make_shared allocates which results in an infinite loop: operator new is called which attempts to access the static AllocationHooks object which does not yet exist - so the constructor gets called again, which then calls operator new again, and so round and round it goes - which unfortunately renders that feature unusable at the moment.
As nice as maintaining a unified approach to handling listeners would be, I don't think there's much need to support multiple listeners as AllocationHooks primary reason for existence is UnitTestAllocationChecker so I've simplified it to handle a single Listener only.