Replaces DynamicArena by LinearAllocator for GUI

Also DynamicArena causes an assertion when there are too many GUI
elements. LinearAllocator consumes similar amount of memory in total
but reduces a chance to get the assertion.
This commit is contained in:
Vladislav Belov committed 2026-10-22 23:22:35 +02:00
1 parent ddc07f92b9
commit 3d8a808b21
1 file changed
+4 -5
+4 -5
View File
@@ -22,8 +22,8 @@
#include "gui/ObjectBases/IGUIObject.h"
#include "lib/alignment.h"
#include "lib/allocators/DynamicArena.h"
#include "ps/memory/AllocatorAdapter.h"
#include "ps/memory/LinearAllocator.h"
#include <algorithm>
#include <utility>
@@ -59,11 +59,10 @@ public:
template<typename... Args>
static void RecurseVisibleObject(IGUIObject* object, void(IGUIObject::* callbackFunction)(Args... args), Args&&... args)
{
using Arena = Allocators::DynamicArena<128 * KiB>;
using ObjectListAllocator = PS::Memory::AllocatorAdapter<VisibleObject, Arena>;
Arena arena;
PS::Memory::LinearAllocator allocator{128 * KiB, 4 * MiB};
using ObjectListAllocator = PS::Memory::AllocatorAdapter<VisibleObject, PS::Memory::LinearAllocator>;
std::vector<VisibleObject, ObjectListAllocator> visibleObjects((ObjectListAllocator(arena)));
std::vector<VisibleObject, ObjectListAllocator> visibleObjects((ObjectListAllocator(allocator)));
CollectVisibleObjectsRecursively(object->GetVisibleChildren(), &visibleObjects);
for (VisibleObject& visibleObject : visibleObjects)
visibleObject.bufferedZ = visibleObject.object->GetBufferedZ();