trouble tracking memory leaks

Home / Forums / Marmalade Archive / Marmalade System / trouble tracking memory leaks
3 replies [Last post]
by: Anton Shekhovtsov
Status: Offline
Joined: 2012-04-13
Points: 420

I have output like this with IwMemBucketDebugCheck:

bucket\System allocated\2787 num\[8] FirstID\59479

I cannot use FirstID since this leak is floating.
What I could possibly use, is to track which allocation has specific size and or specific data. However the log does not show info on individual blocks.
Neither I see run time interface to enumerate blocks.

I can override malloc by s3eMemorySetUserMemMgr but this does not work with buckets. Moreover, I cant find how to disable creation/use of buckets.

Next thing I thought about is to override symbols "malloc,realloc,free" with globally included header.

I dont assume inserting IW_CALLSTACK by binary chop since this is ridiculously long.

So what is your ideas on doing this?

P.S. I found that skipping IwUtilInit() has no harm atm and disables use of buckets.

by: Rocifier
Status: Offline
Joined: 2011-04-05
Points: 2370
This is the most difficult

This is the most difficult problem to fix in my opinion. Especially if it's corrupting other memory. I've encountered similar memory leaks a number of times. I've tried all these strategies, except for disabling buckets, this is not a wise idea with marmalade. I've used every trace option available in marmalade, and used at least 5 different memory leak detection tools.

What I've found from my experience is that the best way to find the problem is to:
1) Remember as hard as you possibly can what you've added to the code that could of caused this leak, even if it's only remotely related to the leak.
2) Read your code thoroughly, and STEP THROUGH IT. I've made epic discoveries with finding memory leaks by stepping through basically every line of code in our games. This is time consuming, but no where near as time consuming as other techniques.
3) Make it a practice to use IW_CALLSTACK functions at the beginning of every significant function (most of them)
4) Using visual C++ memory view windows to analyse corrupted memory, if an object crashes for strange reasons, you can often view it's memory and see what is being written there and guess what object or data type is broken and writing itself. For example, I had one case where a 0 byte was injected into random places of code, but had no way of telling how that happened. I guessed it was a boolean value and stepped through all my code. I found that I was having an object delete itself at once point and then setting a boolean on the object after it was deleted, corrupting other memory.

Overriding new, delete, etc have never found me any success.

by: DeMoney
Status: Offline
Joined: 2011-11-30
Points: 4340
Just curious, why overriding

Just curious, why overriding memory manager is not working with buckets?
As i understand how it works - use bucket, get memory manager that uses that bucket with s3eMemoryGetUserMemMgr, install your own manager, that looks for leaks etc. and then calls functions from that bucket's manager.

by: Anton Shekhovtsov
Status: Offline
Joined: 2012-04-13
Points: 420
DeMoney:

DeMoney:

How it works:
The first and the last hit on my customized malloc is 19 bytes and shows stacktrace to s3eBucketCreate. The rest of the game bypasses customized malloc.

Just realized that IwUtilInit does s3eMemorySetUserMemMgr on its own. Thanks for the hint!

Latest Posts

Latest Comments

Top Contributors

  • Chris D : 27,010
  • MonRoyals : 26,970
  • Salman : 26,720
  • Jez Hammond : 20,130
  • pjan : 11,150
  • gjw : 10,350
  • Paolo Oliverio : 9,640
  • Beaker_2 : 8,390
  • Kite : 8,210
  • bluescrn : 7,810