Memory leak in t2dTileLayer objects (iTGB 1.4) [SOLVED]
by Richard Skala · in iTorque 2D · 12/11/2010 (11:21 pm) · 6 replies
I've been running the "Leaks" Instrument to detect any memory leaks running the game, and it detected a leak in the following function:
which was called from:
Does anyone know anything about this? I haven't found any related threads regarding it. Any help is greatly appreciated.
t2dTileLayer::createLayer(unsigned int, unsigned int, float, float)
which was called from:
t2dTileLayer::setLayerFile(void*, char const*)
Does anyone know anything about this? I haven't found any related threads regarding it. Any help is greatly appreciated.
About the author
Founded in 2009, Pixel Vandals Inc. is focused on bringing fun, fresh, and new ideas to the iPhone. www.pixelvandals.com www.pixelvandals.com/vineking
#2
12/12/2010 (1:38 am)
I see that createlayer does not make a sense, but why would you not call delete unless you want a memory leak cause the old one is not gone?
#3
12/12/2010 (2:13 am)
True. It is probably a good idea to put object->deleteLayer() before the call to object->createLayer(...) in that load method.
#4
Sorry for bumping this old thread,but I have a question.
In regards to the "Leaks" Instrument -- is this something within ITGB 1.41?
or is this something in Xcode?
Any Links or info about this would be appreciated.
04/28/2011 (3:43 am)
@Richard,@MarcSorry for bumping this old thread,but I have a question.
In regards to the "Leaks" Instrument -- is this something within ITGB 1.41?
or is this something in Xcode?
Any Links or info about this would be appreciated.
#5
http://developer.apple.com/library/mac/#documentation/Performance/Conceptual/ManagingMemory/Articles/FindingLeaks.html
04/28/2011 (4:19 am)
This is an Xcode tool.http://developer.apple.com/library/mac/#documentation/Performance/Conceptual/ManagingMemory/Articles/FindingLeaks.html
Torque Owner Richard Skala
Pixel Vandals Inc.
=====================================
SOLUTION
=====================================
In the function:
Comment out these two lines in both of the "else-if" blocks:
=====================================
CAUSE
=====================================
It seems those two lines are unnecessary (for my purposes at least), as this call in that same block:
Will end up calling:
Which ends up calling:
This means the second call to createLayer() is allocating mppTileObjectArray without freeing it first. So, I suppose another solution would be to call deleteLayer() before the createLayer() in that IMPLEMENT_T2D_LOAD_METHOD(), although the first seems pointless.