Skip to content

Commit

Permalink
Make allocation fail warning clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
vabold committed Oct 12, 2024
1 parent b67b119 commit 210b5e6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions source/egg/core/Heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ void *Heap::alloc(size_t size, int align, Heap *pHeap) {

constexpr f32 BYTES_TO_MBYTES = 1024.0f * 1024.0f;
f32 heapSizeMB = static_cast<f32>(heapSize) / BYTES_TO_MBYTES;
f32 heapFreeSizeMB = static_cast<f32>(heapFreeSize) / BYTES_TO_MBYTES;
f32 sizeMB = static_cast<f32>(size) / BYTES_TO_MBYTES;

WARN("HEAP ALLOC FAIL (%p, %s):\nFree bytes: %d (%.1fMBytes)\nAlloc bytes: %d "
WARN("HEAP ALLOC FAIL (%p, %s):\nTotal bytes: %d (%.1fMBytes)\nFree bytes: %d "
"(%.1fMBytes)\nAlloc bytes: %d "
"(%.1fMBytes)\nAlign: %d",
currentHeap, currentHeap->getName(), heapFreeSize, heapSizeMB, size, sizeMB,
align);
currentHeap, currentHeap->getName(), heapSize, heapSizeMB, heapFreeSize,
heapFreeSizeMB, size, sizeMB, align);
}

return block;
Expand Down

0 comments on commit 210b5e6

Please sign in to comment.