Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak on shutdown in sceHeap #18966

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions Core/HLE/sceHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ struct Heap {
static std::map<u32, Heap *> heapList;

static Heap *getHeap(u32 addr) {
auto found = heapList.find(addr);
if (found == heapList.end()) {
return NULL;
auto it = heapList.find(addr);
if (it == heapList.end()) {
return nullptr;
}
return found->second;
return it->second;
}

void __HeapDoState(PointerWrap &p) {
Expand All @@ -73,6 +73,13 @@ void __HeapInit() {
heapList.clear();
}

void __HeapShutdown() {
for (auto it : heapList) {
delete it.second;
}
heapList.clear();
}

static int sceHeapReallocHeapMemory(u32 heapAddr, u32 memPtr, int memSize) {
ERROR_LOG_REPORT(HLE,"UNIMPL sceHeapReallocHeapMemory(%08x, %08x, %08x)", heapAddr, memPtr, memSize);
return 0;
Expand Down
4 changes: 3 additions & 1 deletion Core/HLE/sceHeap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
#pragma once

void Register_sceHeap();

void __HeapInit();
void __HeapDoState(PointerWrap &p);
void __HeapShutdown();
void __HeapDoState(PointerWrap &p);
1 change: 1 addition & 0 deletions Core/HLE/sceKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ void __KernelShutdown()
__AtracShutdown();
__AudioShutdown();
__IoShutdown();
__HeapShutdown();
__KernelMutexShutdown();
__KernelThreadingShutdown();
__KernelMemoryShutdown();
Expand Down