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

Potential memory leak in sceHeap #18952

Closed
2 of 5 tasks
Nemoumbra opened this issue Mar 26, 2024 · 4 comments · Fixed by #18966
Closed
2 of 5 tasks

Potential memory leak in sceHeap #18952

Nemoumbra opened this issue Mar 26, 2024 · 4 comments · Fixed by #18966
Milestone

Comments

@Nemoumbra
Copy link
Contributor

Game or games this happens in

Not game-specific

What area of the game / PPSSPP

CLion's code inspection noticed that the function sceHeapCreateHeap (defined here) allocates the Heap object with operator new and saves its address in the heapList, after which the variable that holds onto the pointer goes out of scope as the function ends. CLion thought it's a leak, but I didn't believe it and went to check how the heapList is managed.

  1. heapList is a static variable and it's only available in its *.cpp file.
  2. getHeap is a static function.
  3. The only operator delete that can be used to deallocate the previously saved heap instance is located in the HLE function sceHeapDeleteHeap.

I don't think the emu can prevent the leak if the user reloads the game, exists the game or loads a savestate.

What should happen

I don't think it's a very important leak (considering I couldn't remember a single game that uses sceHeap right away, it's not too widely used), but it's just way too blatant. Gotta fix that.

Interestingly enough, we've got 3 unimplemented functions in this module. Maybe for another time...

(By the way, please consider renaming found to it or iter here, because auto found suggests a boolean value).

Logs

No response

Platform

Windows

Mobile device model or graphics card (GPU)

AMD Radeon(TM) Graphics

PPSSPP version affected

Self-built version (one of the lastest)

Last working version

No response

Graphics backend (3D API)

Direct3D 11

Checklist

  • Test in the latest git build in case it's already fixed.
  • Search for other reports of the same issue.
  • Try resetting settings or older versions and include if the issue is related.
  • Try without any cheats and without loading any save states.
  • Include logs or screenshots of issue.
@anr2me
Copy link
Collaborator

anr2me commented Apr 1, 2024

@hrydgard hrydgard added this to the v1.18.0 milestone Apr 1, 2024
@efonte
Copy link

efonte commented Apr 1, 2024

here is a list of games that contain the string sceHeap inside the eboot file:

Aku Daikan Manyuki (Japan)/SYSDIR/EBOOT.BIN
Everybody's Stress Buster (Asia) (En,Zh,Ko)/SYSDIR/EBOOT.BIN
Everybody's Tennis (Europe) (En,Fr,De,Es,It)/SYSDIR/EBOOT.BIN
Hanayaka Nari, Wa ga Ichizoku (Japan)/SYSDIR/EBOOT.BIN
Hanayaka Nari, Wa ga Ichizoku - Kinema Mosaic (Japan)/SYSDIR/EBOOT.BIN
Higurashi no Naku Koro ni - Jan (Japan)/SYSDIR/EBOOT.BIN
Hot Shots Tennis - Get a Grip (USA) (En,Fr,Es)/SYSDIR/EBOOT.BIN
Maru Goukaku Shikaku Dasshu! - Care Manager Shiken Portable (Japan)/SYSDIR/EBOOT.BIN
Minna no Sukkiri (Asia)/SYSDIR/EBOOT.BIN
Minna no Tennis Portable (Japan)/SYSDIR/EBOOT.BIN
Senritsu no Stratus (Japan)/SYSDIR/EBOOT.BIN
Star Driver - Kagayaki no Takuto - Ginga Bishounen Densetsu (Japan, Asia)/SYSDIR/EBOOT.BIN

@efonte
Copy link

efonte commented Apr 1, 2024

Here is another list of games that have the libheap.prx module:

Activision Hits Remixed (Europe)/USRDIR/MODULES/LIBHEAP.PRX
Activision Hits Remixed (USA)/USRDIR/MODULES/LIBHEAP.PRX
After Burner - Black Falcon (Europe) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
After Burner - Black Falcon (Europe) (En,Fr,De,Es,It) (Alt)/USRDIR/module/libheap.prx
After Burner - Black Falcon (USA) (En,Fr,Es,It,Nl)/USRDIR/module/libheap.prx
Asphalt - Urban GT 2 (Europe) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
Bakemonogatari Portable (Japan)/USRDIR/MODULE/libheap.prx
Battle vs. Chess (Europe) (En,Fr,De,Es,It,Pl,Ru) (Proto) (2011-12-15)/USRDIR/data/module/LIBHEAP.PRX
Ben 10 - Protector of Earth (Europe)/USRDIR/module/libheap.prx
Ben 10 - Protector of Earth (Europe) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
Ben 10 - Protector of Earth (USA)/USRDIR/module/libheap.prx
Black Rock Shooter - The Game (Japan)/USRDIR/MODULES/LIBHEAP.PRX
Bleach - Heat the Soul 4 (Japan)/USRDIR/data/module/libheap.prx
Bleach - Heat the Soul 5 (Japan)/USRDIR/data/module/libheap.prx
Bleach - Heat the Soul 6 (Asia)/USRDIR/data/module/libheap.prx
Bleach - Heat the Soul 6 (Japan)/USRDIR/data/module/libheap.prx
Bleach - Heat the Soul 7 (Japan)/USRDIR/data/module/libheap.prx
Bleach - Heat the Soul 7 (Korea)/USRDIR/data/module/libheap.prx
Blokus Club Portable with Bumpy Trot (Japan) (Taikenban)/USRDIR/module/libheap.prx
Blokus Portable - Steambot Championship (Europe) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
Blokus Portable - Steambot Championship (USA)/USRDIR/module/libheap.prx
Bomberman (Europe) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
Brian Lara 2007 - Pressure Play (Europe)/USRDIR/libheap.prx
Brooktown High (USA)/USRDIR/MODULES/LIBHEAP.PRX
Brothers in Arms - D-Day (USA)/USRDIR/SYSTEM/PSP_MODULES/LIBHEAP.PRX
Capcom Puzzle World (Europe)/USRDIR/Modules/libheap.prx
Capcom Puzzle World (USA)/USRDIR/Modules/libheap.prx
Code Lyoko - Quest for Infinity (Europe) (En,Fr,Es,It)/USRDIR/module/libheap.prx
Code Lyoko - Quest for Infinity (USA) (En,It)/USRDIR/module/libheap.prx
Coded Soul - Gyeseungdoeneun Idea (Korea) (Ja,Ko)/USRDIR/MODULE/LIBHEAP.PRX
Coded Soul - Uketsugareshi Idea (Japan)/USRDIR/MODULE/LIBHEAP.PRX
Cover Girl (Europe) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
Death Jr. II - Root of Evil (Europe) (En,Fr,De,Es,It)/USRDIR/MODULES/LIBHEAP.PRX
Death Jr. II - Root of Evil (USA)/USRDIR/MODULES/LIBHEAP.PRX
Disney TRON - Evolution (Europe) (En,Fr,De,Es,It,Nl)/USRDIR/modules/libheap.prx
Disney TRON - Evolution (Russia)/USRDIR/modules/libheap.prx
Disney TRON - Evolution (USA) (En,Fr,Es)/USRDIR/modules/libheap.prx
EA Replay (Europe) (En,De,Es,It,Nl)/USRDIR/module/libheap.prx
EA Replay (USA)/USRDIR/module/libheap.prx
Echochrome (Europe) (En,Fr,De,Es,It,Nl,Pt,Ru) (Beta) (2008-05-13)/USRDIR/module/libheap.prx
Echochrome (Europe) (En,Fr,De,Es,It,Nl,Pt,Ru) (Demo)/USRDIR/module/libheap.prx
Echochrome (Europe, Australia) (En,Fr,De,Es,It,Nl,Pt,Ru)/USRDIR/module/libheap.prx
Echochrome - Muhan Hoerang (Korea) (En,Zh,Ko)/USRDIR/module/libheap.prx
Fat Princess - Fistful of Cake (Europe, Australia) (En,Fr,De,Es,It,Nl,Pt,Ru)/USRDIR/modules/libheap.prx
Fat Princess - Fistful of Cake (USA)/USRDIR/modules/libheap.prx
Fate-Tiger Colosseum Upper (Japan)/USRDIR/module/libheap.prx
Fate-Unlimited Codes Portable (Japan)/USRDIR/data/module/libheap.prx
Generation of Chaos (Europe)/USRDIR/GOCEDATA/MODULES/libheap.prx
Gitaroo Man Lives! (USA)/USRDIR/PRX/MODULE/LIBHEAP.PRX
God of War - Chains of Olympus (Asia) (En,Zh)/USRDIR/module/libheap.prx
God of War - Chains of Olympus (Europe) (Beta) (2008-02-02)/USRDIR/module/libheap.prx
God of War - Chains of Olympus (Europe) (Demo)/USRDIR/module/libheap.prx
God of War - Chains of Olympus (Europe, Australia) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
God of War - Chains of Olympus (Korea)/USRDIR/module/libheap.prx
God of War - Chains of Olympus (USA)/USRDIR/module/libheap.prx
God of War - Chains of Olympus - Battle of Attica (USA) (Demo)/USRDIR/module/libheap.prx
God of War - Chains of Olympus - Special Edition - Battle of Attica (USA) (Demo)/USRDIR/module/libheap.prx
God of War - Ghost of Sparta (Asia) (En,Zh,Ko)/USRDIR/MODULE/LIBHEAP.PRX
God of War - Ghost of Sparta (Europe) (En,Pl,Ru)/USRDIR/MODULE/LIBHEAP.PRX
God of War - Ghost of Sparta (Europe, Australia) (En,Fr,De,Es,It)/USRDIR/MODULE/LIBHEAP.PRX
God of War - Ghost of Sparta (USA) (En,Fr,Es)/USRDIR/MODULE/LIBHEAP.PRX
God of War - Koutan no Kokuin (Japan) (En,Ja)/USRDIR/MODULE/LIBHEAP.PRX
God of War - Rakujitsu no Hisoukyoku (Japan)/USRDIR/module/libheap.prx
Intelligent License 2 (Japan)/USRDIR/module/libheap.prx
Irem Taikenban Shuu 2008 Shunki Tokubetsugou (Japan)/USRDIR/V1/MODULE/libheap.prx
J.League Pro Soccer Club o Tsukurou! 7 - Euro Plus (Japan)/USRDIR/bin/module/libheap.prx
Judie no Atelier - Gramnad no Renkinjutsushi - Toraware no Moribito (Japan)/USRDIR/res/module/libheap.prx
Kamen Rider - Climax Heroes OOO (Japan)/USRDIR/data/module/libheap.prx
Kamen Rider - Super Climax Heroes (Japan)/USRDIR/data/module/libheap.prx
Kidou Senshi Gundam - Gihren no Yabou - Axis no Kyoui (Japan)/USRDIR/libheap.prx
Kidou Senshi Gundam - Gihren no Yabou - Axis no Kyoui V (Japan)/USRDIR/libheap.prx
Last Ranker (Japan)/USRDIR/MODULES/LIBHEAP.PRX
Legend of the Dragon (Europe) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
Legend of the Dragon (USA)/USRDIR/module/libheap.prx
Marvel - Ultimate Alliance (Europe) (En,It)/USRDIR/module/libheap.prx
Marvel - Ultimate Alliance (USA) (v1.02)/USRDIR/module/libheap.prx
Marvel - Ultimate Alliance (USA) (v2.00)/USRDIR/module/libheap.prx
Marvel - Ultimate Alliance 2 (Europe)/USRDIR/modules/libheap.prx
Marvel - Ultimate Alliance 2 (USA)/USRDIR/modules/libheap.prx
Medal of Honor - Heroes (Europe)/USRDIR/module/libheap.prx
Medal of Honor - Heroes (France)/USRDIR/module/libheap.prx
Medal of Honor - Heroes (Germany)/USRDIR/module/libheap.prx
Medal of Honor - Heroes (Italy)/USRDIR/module/libheap.prx
Medal of Honor - Heroes (Japan)/USRDIR/module/libheap.prx
Medal of Honor - Heroes (Netherlands)/USRDIR/module/libheap.prx
Medal of Honor - Heroes (Spain)/USRDIR/module/libheap.prx
Medal of Honor - Heroes (USA)/USRDIR/module/libheap.prx
Metal Gear Solid - Peace Walker (Europe, Australia) (En,Fr,De,Es,It)/USRDIR/modules/libheap.prx
Metal Gear Solid - Peace Walker (Japan) (v1.03)/USRDIR/modules/libheap.prx
Metal Gear Solid - Peace Walker (Japan, Asia) (v1.02)/USRDIR/modules/libheap.prx
Metal Gear Solid - Peace Walker (USA) (En,Fr,Es) (v1.01)/USRDIR/modules/libheap.prx
Metal Gear Solid - Peace Walker (USA) (En,Fr,Es) (v2.00)/USRDIR/modules/libheap.prx
Metal Gear Solid - Portable Ops (Europe) (En,Fr,De,Es,It)/USRDIR/modules/libheap.prx
Metal Gear Solid - Portable Ops (Japan) (v1.00)/USRDIR/modules/libheap.prx
Metal Gear Solid - Portable Ops (Japan, Asia) (v1.02)/USRDIR/modules/libheap.prx
Metal Gear Solid - Portable Ops (Korea)/USRDIR/modules/libheap.prx
Metal Gear Solid - Portable Ops (USA)/USRDIR/modules/libheap.prx
Metal Gear Solid - Portable Ops Plus (Asia)/USRDIR/modules/libheap.prx
Metal Gear Solid - Portable Ops Plus (Europe) (En,Fr,De,Es,It)/USRDIR/modules/libheap.prx
Metal Gear Solid - Portable Ops Plus (Japan)/USRDIR/modules/libheap.prx
Metal Gear Solid - Portable Ops Plus (USA)/USRDIR/modules/libheap.prx
Moegaku @ Portable (Japan) (En,Ja)/USRDIR/GAMEDATA/MODULES/libheap.prx
Monster Kingdom - Jewel Summoner (USA)/USRDIR/module/libheap.prx
Monster Kingdom - Jewel Summoner (USA) (Demo)/USRDIR/module/libheap.prx
Mugen Kairou (Japan)/USRDIR/module/libheap.prx
Mugen Kairou (Japan) (Beta) (2007-12-18)/USRDIR/module/libheap.prx
NHL 07 (Europe) (En,Fr,De)/USRDIR/module/libheap.prx
NHL 07 (USA)/USRDIR/module/libheap.prx
PQ2 - Practical Intelligence Quotient 2 (USA)/USRDIR/module/libheap.prx
Practical IQ - Test Your Intelligence (Europe) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
PSP Camera 01 (Japan)/USRDIR/module/libheap.prx
PSP Camera 03 (Japan)/USRDIR/module/libheap.prx
Ragnarok - Hikari to Yami no Koujo (Japan)/USRDIR/system/module/libheap.prx
Ragnarok Tactics (USA)/USRDIR/system/module/libheap.prx
Ricky Ponting 2007 - Pressure Play (Australia)/USRDIR/libheap.prx
Scooby-Doo! Qui Regarde Qui (France) (En,Fr)/USRDIR/MODULE/libheap.prx
Scooby-Doo! Who's Watching Who (Europe)/USRDIR/MODULE/libheap.prx
Scooby-Doo! Who's Watching Who (Europe) (Es,It)/USRDIR/MODULE/libheap.prx
Scooby-Doo! Who's Watching Who (USA)/USRDIR/MODULE/libheap.prx
Sengoku Efuda Yuugi - Hototogisu Ran (Japan)/USRDIR/module/libheap.prx
Sengoku Efuda Yuugi - Hototogisu Tairan (Japan)/USRDIR/module/libheap.prx
Senritsu no Stratus (Japan)/USRDIR/module/libheap.prx
Shadow of Destiny (USA)/USRDIR/MODULE/LIBHEAP.PRX
Shadow of Memories (Japan)/USRDIR/MODULE/LIBHEAP.PRX
Shirogane no Cal to Aoi no Joou (Japan)/USRDIR/DEVKIT/MODULE/LIBHEAP.PRX
Sims 2, The - Pets (Asia) (En,Fr,De,Es,It,Nl,Zh)/USRDIR/module/libheap.prx
Singi Hwansang - SSII Unlimited Side (Korea)/USRDIR/SOUKDATA/MODULES/libheap.prx
Sonic Rivals (Europe) (En,Fr,De,Es,It)/USRDIR/MODULES/LIBHEAP.PRX
Sonic Rivals (USA)/USRDIR/MODULES/LIBHEAP.PRX
Sonic Rivals 2 (Europe) (En,Fr,De,Es,It)/USRDIR/MODULES/LIBHEAP.PRX
Sonic Rivals 2 (USA)/USRDIR/MODULES/LIBHEAP.PRX
Spectral Souls - Resurrection of the Ethereal Empires (USA)/USRDIR/SOUEDATA/MODULES/libheap.prx
Spectral vs. Generation (Europe)/USRDIR/GAMEDATA/MODULES/libheap.prx
Spectral vs. Generation (Japan)/USRDIR/GAMEDATA/MODULES/libheap.prx
StateShift (Europe)/USRDIR/MODULE/LIBHEAP.PRX
Test Drive Unlimited (Europe) (En,Fr,De,Es,It)/USRDIR/PRX/MODULE/LIBHEAP.PRX
Test Drive Unlimited (USA)/USRDIR/PRX/MODULE/LIBHEAP.PRX
To Love Ru - Doki Doki! Rinkai Gakkou Hen (Japan)/USRDIR/prx/libheap.prx
Tom Clancy's Ghost Recon - Predator (Europe) (En,Fr,De,Es,It)/USRDIR/PSPModules/libheap.prx
Tom Clancy's Ghost Recon - Predator (USA) (En,Fr,Es)/USRDIR/PSPModules/libheap.prx
Transformers - Die Rache (Germany)/USRDIR/MODULE/libheap.prx
Transformers - Revenge of the Fallen (Europe) (En,Fr)/USRDIR/MODULE/libheap.prx
Transformers - Revenge of the Fallen (Europe) (Es,It)/USRDIR/MODULE/libheap.prx
Transformers - Revenge of the Fallen (Korea)/USRDIR/MODULE/libheap.prx
Transformers - Revenge of the Fallen (USA) (En,Fr)/USRDIR/MODULE/libheap.prx
Transformers - The Game (Europe)/USRDIR/MODULE/libheap.prx
Transformers - The Game (Europe) (De,It)/USRDIR/MODULE/libheap.prx
Transformers - The Game (Europe) (Fr,Es)/USRDIR/MODULE/libheap.prx
Transformers - The Game (USA)/USRDIR/MODULE/libheap.prx
Viorate no Atelier - Gramnad no Renkinjutsushi 2 - Gunjou no Omoide (Japan)/USRDIR/res/module/libheap.prx
Warning - Code de la Route (France)/USRDIR/GAMEDATA/MODULES/libheap.prx
Winx Club - Join the Club (Europe) (En,Fr,De,Es,It)/USRDIR/KMODULE/LIBHEAP.PRX
Winx Club - Join the Club (USA)/USRDIR/KMODULE/LIBHEAP.PRX
WWII - Battle over the Pacific (Europe)/USRDIR/module/libheap.prx
Yu-Gi-Oh! Duel Monsters GX - Tag Force 2 (Japan)/USRDIR/module/libheap.prx
Yu-Gi-Oh! Duel Monsters GX Tag Force (Japan)/USRDIR/module/libheap.prx
Yu-Gi-Oh! GX - Tag Force (Europe) (En,Fr,De,Es,It)/USRDIR/module/libheap.prx
Yu-Gi-Oh! GX - Tag Force (USA)/USRDIR/module/libheap.prx
Yu-Gi-Oh! GX - Tag Force 2 (Europe) (En,Fr,De,Es,It) (v1.01)/USRDIR/module/libheap.prx
Yu-Gi-Oh! GX - Tag Force 2 (Europe) (En,Fr,De,Es,It) (v2.00)/USRDIR/module/libheap.prx
Yu-Gi-Oh! GX - Tag Force 2 (USA)/USRDIR/module/libheap.prx

@hrydgard
Copy link
Owner

hrydgard commented Apr 1, 2024

No need to dig for more examples, these will do nicely, thanks.

GermanAizek added a commit to GermanAizek/ppsspp that referenced this issue Apr 2, 2024
GermanAizek added a commit to GermanAizek/ppsspp that referenced this issue Apr 2, 2024
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 a pull request may close this issue.

4 participants