Skip to content

Match phys::System heap accessors - #185

Merged
Pistonight merged 1 commit into
zeldaret:masterfrom
RobbyV2:phys-system-heap-accessors
Jul 31, 2026
Merged

Match phys::System heap accessors#185
Pistonight merged 1 commit into
zeldaret:masterfrom
RobbyV2:phys-system-heap-accessors

Conversation

@RobbyV2

@RobbyV2 RobbyV2 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

isHavokMainHeapOom returns true when the Havok main heap free size divided by its total size is below 0.05.

The allocator sits at this+0x78, inside the old _78 padding, so I added HavokMemoryAllocator* mHavokAllocator and shortened the padding to _80.

getPhysicsTempHeap returns mPhysicsTempDefaultHeap when low_priority is LowPriority::No and the current thread priority is at most sead::Thread::cDefaultPriority, dumping that heap first when getMaxAllocatableSize(8) is at most 0x2800. Every other case returns mPhysicsTempLowHeap.


This change is Reviewable

@Pistonight Pistonight left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pistonight made 3 comments.
Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on RobbyV2).


src/KingSystem/Physics/System/physSystem.cpp line 3 at r1 (raw file):

#include "KingSystem/Physics/System/physSystem.h"
#include <heap/seadHeap.h>
#include <thread/seadThread.h>

looks like other files also have this issue but ...
can we put <> imports above "" imports?
( we should probably fix the clang format rules)


src/KingSystem/Physics/System/physSystem.cpp line 80 at r1 (raw file):

bool System::isHavokMainHeapOom() const {
    return f32(mHavokAllocator->getHeapFreeSize()) / f32(mHavokAllocator->getHeapSize()) < 0.05f;

nit: prefer c++ cast static_cast<f32>


src/KingSystem/Physics/System/physSystem.cpp line 91 at r1 (raw file):

        return mPhysicsTempDefaultHeap;
    }
    return mPhysicsTempLowHeap;

does changing to guard-style work?

if (low_priority != LowPriority::No) {
   return mPhysicsTempLowHeap;
}
if (sead::ThreadMgr::instance()->getCurrentThread()->getPriority() > sead::Thread::cDefaultPriority) {
   return mPhysicsTempLowHeap;
}
if (mPhysicsTempDefaultHeap->getMaxAllocatableSize(8) <= 0x2800)
            mPhysicsTempDefaultHeap->dump();
return mPhysicsTempDefaultHeap;

@RobbyV2
RobbyV2 force-pushed the phys-system-heap-accessors branch from aaacee0 to c6c8bea Compare July 30, 2026 13:07
@RobbyV2

RobbyV2 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Done. The two guards are folded into one condition because the split form does not match.

@RobbyV2
RobbyV2 requested a review from Pistonight July 30, 2026 13:32
@Pistonight
Pistonight merged commit 7c65472 into zeldaret:master Jul 31, 2026
3 of 4 checks passed
@RobbyV2
RobbyV2 deleted the phys-system-heap-accessors branch July 31, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants