View Issue Details

IDProjectCategoryView StatusLast Update
0002427NoesisGUIC++ SDKpublic2025-10-05 11:57
Reporterjsantos Assigned Tojsantos  
PrioritynormalSeverityfeature 
Status assignedResolutionopen 
Product Version3.1 
Summary0002427: Improvement to memory callbacks
Description

Right now there are a few annoyances in our memory callbacks that must be fixed:

  • allocSize() callback is not easy to implement by many clients. We should remove this and keep the size internally when memory tracking is active. We should also offer a method to disable memory tracking at runtime (for clients without source code).
  • realloc() should provide the oldsize too to help customers with advanced allocators

We should also expose a category enum for each allocator to classify memory usage stats.

PlatformAny

Activities

jsantos

jsantos

2025-09-05 17:47

manager   ~0011032

Last edited: 2025-10-05 11:57

There are also issues with alignment. If a class derived from BaseComponent requires non-standard alignment (for example, when using __m256), this requirement is not propagated to Noesis allocators, which prevents client code from handling it correctly. In C++17, operator new provides an overload that includes alignment information, which could be used to pass this requirement to our allocators. The allocation size is also available, so we could forward it to the client in dealloc and realloc operations.

A far from ideal solution is implementing AlignedAlloc on top of current allocators:

void* AlignedAlloc(size_t size, size_t alignment)
{
    size_t total = size + alignment - 1 + sizeof(void*);
    void* ptr = Noesis::Alloc(total);

    uintptr_t rawAddr = (uintptr_t)ptr + sizeof(void*);
    uintptr_t alignedAddr = (rawAddr + alignment - 1) & ~(uintptr_t)(alignment - 1);
    void* aligned = (void*)alignedAddr;

    ((void**)aligned)[-1] = ptr;

    return aligned;
}

void AlignedDealloc(void* ptr)
{
    void* raw = ((void**)ptr)[-1];
    Noesis::Dealloc(raw);
}

Issue History

Date Modified Username Field Change
2022-09-21 13:40 jsantos New Issue
2022-09-21 13:40 jsantos Assigned To => jsantos
2022-09-21 13:40 jsantos Status new => assigned
2022-09-21 13:41 jsantos Description Updated
2022-09-21 13:41 jsantos Description Updated
2022-09-21 13:41 jsantos Description Updated
2025-09-05 17:47 jsantos Note Added: 0011032
2025-09-05 17:50 jsantos Note Edited: 0011032
2025-09-05 17:50 jsantos Note Edited: 0011032
2025-10-05 11:57 jsantos Note Edited: 0011032