[SOLVED] BUG ALL ITGB VERSIONS - Serious Memory leaks on objects collisions system
by Edoardo · in iTorque 2D · 06/28/2010 (3:07 am) · 60 replies
Build: All iTGB versions
Platform: OS X 10.6.4, Simulator iPhone
Target: On Device and on Simulator
Issues: Serious Memory leaks on objects collisions system possible cause Dictionary.cc
Steps to Repeat:
1. Run "iphoneTest" project on simulator or on device
2. remove PUAP_SCRIPT_CHANGE definition.
3. run the game with leaks instruments
4. Click "bounce" on the game screen
Suggested Fix: The problem the dealloc of mHashTable into Dictionary.cc
------------------------------------------------------------------------------------------------------------------------------
Hi all,
I've discovered serious memory leaks on collition systems when i remove from definitions PUAP_SCRIPT_CHANGE... .I did the tests from version 1.1 to version 1.4 of iTgb (and all have the same problem)
In my game I've memory leaks of approximately 1 MB per minute... :-(
If anyone can solve it.... to recreate the problem simply install the "iPhoneTest", with leaks Instruments and use the bounce mode.
After a few minutes you will notice a significant loss of memory.
In a game like mine where there are many collisions per second causes a crash after a few minutes.
I can't use PUAP_SCRIPT_CHANGE because my game is based on PSK: www.torquepowered.com/community/forums/viewthread/112599/1#comment-733991
I USE IN TEST THIS DEFINITIONS:
__IPHONE__
TORQUE_PLAYER
TORQUE_RELEASE
TORQUE_DISABLE_MEMORY_MANAGER
PUAP_OPTIMIZE
USE_COMPONENTS
This is a screenshoot of my instruments :

Platform: OS X 10.6.4, Simulator iPhone
Target: On Device and on Simulator
Issues: Serious Memory leaks on objects collisions system possible cause Dictionary.cc
Steps to Repeat:
1. Run "iphoneTest" project on simulator or on device
2. remove PUAP_SCRIPT_CHANGE definition.
3. run the game with leaks instruments
4. Click "bounce" on the game screen
Suggested Fix: The problem the dealloc of mHashTable into Dictionary.cc
------------------------------------------------------------------------------------------------------------------------------
Hi all,
I've discovered serious memory leaks on collition systems when i remove from definitions PUAP_SCRIPT_CHANGE... .I did the tests from version 1.1 to version 1.4 of iTgb (and all have the same problem)
In my game I've memory leaks of approximately 1 MB per minute... :-(
If anyone can solve it.... to recreate the problem simply install the "iPhoneTest", with leaks Instruments and use the bounce mode.
After a few minutes you will notice a significant loss of memory.
In a game like mine where there are many collisions per second causes a crash after a few minutes.
I can't use PUAP_SCRIPT_CHANGE because my game is based on PSK: www.torquepowered.com/community/forums/viewthread/112599/1#comment-733991
I USE IN TEST THIS DEFINITIONS:
__IPHONE__
TORQUE_PLAYER
TORQUE_RELEASE
TORQUE_DISABLE_MEMORY_MANAGER
PUAP_OPTIMIZE
USE_COMPONENTS
This is a screenshoot of my instruments :

About the author
The creator of HOOGA (available on Apple Store)
#2
06/28/2010 (7:00 am)
Interesting that you have discovered this. Any idea on which class/method in the engine has the leak? We could look at that and try and figure out the problem.
#4
06/28/2010 (7:26 am)
Are these objects being constantly built and destroyed?
#5
without PUAP_SCRIPT_CHANGE the references are builded but not destroyed...
06/28/2010 (7:31 am)
with PUAP_SCRIPT_CHANGE yes...without PUAP_SCRIPT_CHANGE the references are builded but not destroyed...
#6
06/28/2010 (7:48 am)
Yes, I saw that in the destructor.
#7
I have not C/C++ experience to resolve this problem...
06/28/2010 (7:52 am)
Can you resolve the problem? I'm desperate!!!I have not C/C++ experience to resolve this problem...
#8
1. Manually activate the PUAP_SCRIPT_CHANGE modifications so they are always on for Dictionary.cc
2. Avoid using Dynamic Fields. Now this I'm not sure about. In the other thread, Phil said that dynamic fields do not work with the PSK. However, I have dynamic fields working in iT2D 1.4. I have to investigate this further.
06/28/2010 (7:57 am)
@TheItalianJob - I believe you have two options, while I look into this:1. Manually activate the PUAP_SCRIPT_CHANGE modifications so they are always on for Dictionary.cc
2. Avoid using Dynamic Fields. Now this I'm not sure about. In the other thread, Phil said that dynamic fields do not work with the PSK. However, I have dynamic fields working in iT2D 1.4. I have to investigate this further.
#9
The problem on PSK If I enable PUAP_SCRIP_CHANGE on all iTGB versions the player actor don't collide with platforms...
What changes should I do on Dictionary.cc to eliminate memory leaks and run PSK correctly?
06/28/2010 (8:04 am)
Thanks Michael but I've tested the "iphoneTest" on the 1.4b (without PUAP_SCRIPT_CHANGE) and the memory leaks persist.The problem on PSK If I enable PUAP_SCRIP_CHANGE on all iTGB versions the player actor don't collide with platforms...
What changes should I do on Dictionary.cc to eliminate memory leaks and run PSK correctly?
#10
06/28/2010 (8:45 am)
This would be my starter for 10 ...Dictionary::~Dictionary()
{
//#ifdef PUAP_SCRIPT_CHANGE
delete mHashTable;
//#endif
}
#11
I've tried this but the console give me a EXC_BAD_ACCESS and the "iPhoneTest" don't start
06/28/2010 (8:48 am)
@ScottI've tried this but the console give me a EXC_BAD_ACCESS and the "iPhoneTest" don't start
#12
06/28/2010 (10:55 am)
As a reminder, please use the Bug Reporting Standard. This makes easier for us to reproduce bugs and log them in our tracker.
#13
06/28/2010 (2:42 pm)
Is there someone who can help me?
#14
Dictionary::~Dictionary()
{
//#ifdef PUAP_SCRIPT_CHANGE
if (mHashTable != NULL) {
delete mHashTable;
}
//#endif
}
[/code]
06/28/2010 (3:16 pm)
What about this:Dictionary::~Dictionary()
{
//#ifdef PUAP_SCRIPT_CHANGE
if (mHashTable != NULL) {
delete mHashTable;
}
//#endif
}
[/code]
#15
Once a user makes heavy modifications to the engine, it's difficult for the engine team to isolate problems. Phil might be the best resource you have at this point.
06/28/2010 (3:18 pm)
@TheItalianJob - It's tough for me to resolve since the PSK is not fully iT2D 1.4 compliant and the combination of the two is causing the issue. We have PUAP_SCRIPT_CHANGE for a reason, it's an optimization. If I can snag some time, I'll see if it's possible to erase the leak...but I do not have the code you are working with.Once a user makes heavy modifications to the engine, it's difficult for the engine team to isolate problems. Phil might be the best resource you have at this point.
#16
when the "delete mHashTable;" run the code below is called
tHashTable.h
06/28/2010 (3:25 pm)
@scott the problem "EXC_BAD_ACCESS" persist ...when the "delete mHashTable;" run the code below is called
tHashTable.h
template<typename Key, typename Value>
void tHashTable<Key,Value>::_destroy()
{
for (S32 i = 0; i < mTableSize; i++)
for (Node* ptr = mTable[i]; ptr; ) //<----This generate the EXC_BAD_ACCESS
{
Node *tmp = ptr;
ptr = ptr->mNext;
delete tmp;
}
delete[] mTable;
mTable = NULL;
}
#17
Unfortunately I can not give you the PSK code without Phillip permission...
but If you have the original version of PSK for TGB the c++ source are identical
06/28/2010 (3:30 pm)
@Michael the code of PSK for iPhone is a beta release of Phillip for iT2D 1.4b (with the same problem)...Unfortunately I can not give you the PSK code without Phillip permission...
but If you have the original version of PSK for TGB the c++ source are identical
#18
I've been trying to help Edoardo out with this for a while now, but unfortunately I'm not sure that I am experiencing the same problems he is.
Regarding the PUAP_SCRIPT_CHANGE directive, I'm pretty certain that it removes support for dynamic fields; which the PlatformerKit relies on. I'll double check this again today to be certain, but if it looks like this directive is required for iTGB to run correctly then it is my responsibility to refactor the PlatformerKit to fit in with the engine. I'll keep you both posted on this point.
06/28/2010 (3:36 pm)
I'm not convinced that the issue is with the PlatformerKit. Though, I suspected it is just highlighting the issue.I've been trying to help Edoardo out with this for a while now, but unfortunately I'm not sure that I am experiencing the same problems he is.
Regarding the PUAP_SCRIPT_CHANGE directive, I'm pretty certain that it removes support for dynamic fields; which the PlatformerKit relies on. I'll double check this again today to be certain, but if it looks like this directive is required for iTGB to run correctly then it is my responsibility to refactor the PlatformerKit to fit in with the engine. I'll keep you both posted on this point.
#19
06/28/2010 (3:38 pm)
Definitely keep me in the loop. Could you also send me the PSK iPhone beta stuff too, since I can compare that with the latest fixes in the 1.4 beta repo.
Torque Owner Edoardo
Default Studio Name