Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Which tools to use to track down a memory leak in a game?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Number84
How do I cheat?
Reputation: 0

Joined: 08 Jul 2023
Posts: 3

PostPosted: Wed Feb 28, 2024 6:56 pm    Post subject: Which tools to use to track down a memory leak in a game? Reply with quote

I'm trying to figure out the cause of a memory leak-related crash in Sheep, Dog 'n' Wolf, an old PC game from 2001. Most of what I know about assembly, computer memory, etc has been self-taught by using Cheat Engine, so there's a lot of stuff that I don't fully understand. I'm hoping someone can point me toward some good next steps to take to try to find the bug or oversight that causes this to happen.

I have a basic idea of what's going on. Every time a level is loaded (including when you restart a level), the game loads the level data and never releases it. If you load Level 5 twenty times, you'll have 20 copies of Level 5's data just taking up space. If you do this enough, the game will eventually crash.
- It doesn't always crash after the same number of level-loads, even when loading the same level over and over.
- It doesn't always crash at the same quantity of memory used.
- In addition to crashing when you try to load a level, the crash can also occur when you press Esc to open the pause menu. This makes me wonder if there's some oversight that causes the game to overwrite level data with dinput data, or vice-versa, when memory gets cramped.

I was able to use the Graphical Memory View to find the region of memory that the level data is being added to, but I'm not sure what to do with that information. My gut says I need to track down the assembly code responsible for looking through that memory region and finding available space, but I haven't had any luck so far. I'm not sure how to use the "watch memory allocations" or "watch memory page access" tools, but they seem like they might be what I'd want to use, yeah?

What tools would you use to try to find the root cause of an issue like this? I'm not sure it's even something that's fixable at this point, but if it is, fixing it would be a huge help. Thanks in advance if anyone has any pointers.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 143

Joined: 06 Jul 2014
Posts: 4380

PostPosted: Wed Feb 28, 2024 7:18 pm    Post subject: Reply with quote

Valgrind is the first thing that comes to my mind.

https://valgrind.org/

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 460

Joined: 09 May 2003
Posts: 25360
Location: The netherlands

PostPosted: Wed Feb 28, 2024 7:47 pm    Post subject: Reply with quote

depends on the allocation method.

virtualalloc or heap?

Then depending on the type write a recording routine that tracks the allocated level info, and on new level delete the older level (a level or 2 behind just in case the old one is still referenced)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites