Game Development Community

Torque X huge memory leak - Fixed

by Giuseppe De Francesco · in Torque X 2D · 03/18/2010 (11:54 am) · 298 replies

Well,

I'm not sure this is the right place to post this, maybe the blog? At any rate I'm posting here now.

Torque X has a huge memory leak, but seriously! I was working to a RPG game for a start so I didn't really notice, but 2 weeks ago I started YASS, a multiplayer side scrolling space shooter: a lot of particles, really a lot, and a lot of projectiles as well.

To let you understand here follows a short video of the game:



This is the memory situation after 3 minutes of gameplay (single player!!!) the game slowed down a lot:

forum.xnaitalia.com/download/leak1.png

So, I searched the forum and I realized that this issue is an old one and GG never got a grip on it (go figure why...) so I decided to fix the problems myself because I really need to publish YASS ;)

Long story short: I revised the whole engine and made a lot of fixes, some of them really of great importance, so here it is the situation playing my game (as you can see after 9 minutes the game still is 20% less than the original 3 minutes!):

forum.xnaitalia.com/download/leak2.png

There are still many stuff to fix, but at any rate in the current state I'm able to publish the game ;) I will make the SVN diff files available upon request (free of charge: pino AT dftgames DOT com).

Cheers,
Pino

About the author

In the software eng. field since 1981, in charge of R&D during last 10 years. IEEE Senior Member (and volunteer).

#241
04/27/2010 (12:47 am)
@Duncan: good idea ;)

@Tony: I'm glad to see that it works fine for you because the Physics part of the FPS Demo is giving me a hell of headache! PRoblem is that it's that way with the original package so it's part of the needed fixes, but it's quite difficult to get a grip on it. I'm starting to fear that it's just too many physics objects on the screen at once... which would be bad news.
#242
04/27/2010 (1:53 am)
The FPS/Physics etc demo was written like 3 versions ago. I really even wonder if it's still valid.
#243
04/27/2010 (6:29 am)
Well Henry, I don't see "strange" code in it, but if you or Tony can produce a similar unit test it would be great: it's just a stockpile of cubes and spheres to shoot at, all having rigid body behaviour.

I'm still fighting with my editor, but maybe I came up with a way to use it... not sure, just experimenting now.
#244
04/27/2010 (2:03 pm)
@Henry: you had some issues with async loader and mounts not showing up in game. Just saw this happen on an older version of the project and it was because the mounts were being added to the wrong scenegraph. Scenegraph stuff has been un-hackified now, so hopefully that will solve the issue you had previously.
#245
04/27/2010 (3:15 pm)
I just tried it, yea man it works!

#246
04/27/2010 (3:20 pm)
@Pino I love your new status! Congrats!

What I was saying about the 3D thing is that it's not just like open builder and add stuff and away we go like the TX2D. They have some code in there that deals with the terrain collisons or something so the guy doesn't fall through.

If you create a scene and a guy he will just slide through as you could see with the example I sent you.

The terrain in that example is also a very very old format, it's terrain version 3, the TX3D engine will take terrain V4, however the tools that we have easily available will not make any terrain older than terrain V5.



#247
04/27/2010 (5:54 pm)
Pino glad to see GG took notice and made you an associate :).
#248
04/27/2010 (11:06 pm)
@Pino I found out why the guy was sinking through the ground in 3D and made a post about it. I can't believe this isn't documented anywhere else.

www.torquepowered.com/community/forums/viewthread/114577

#249
04/28/2010 (5:24 am)
Thanks guys ;)

About the TX3D low frame rate issue... it's not an issue, the logic can be improved but the code to tweak your scene is there already.

I posted the explanation in this thread:
www.torquepowered.com/community/forums/viewthread/114595

Now I'm going to optimise the 3D in the same way of the 2D one ;)

Cheers,
Pino
#250
04/28/2010 (6:51 am)
@Pino: That is awesome!

I will have to revert all my personal changes in my code having to do with that and see how my frame rate is.

When would you like to take a look at my animation changes? I can post them here, email you or just make the changes and submit them to the SVN tree.

As a description to help you decide, basically in the stock TX3D version all models that load the same model resource share a common Shape object. This causes animations to not work right because the animation updating on different models is actually updating the same shape. This is most noticible when you try to play different animations on different models (with the shared shape) at the same time.

The change I made was to simply made the shape clone able and then instead of assigning the same shared shape I create a new shape each time the model is loaded.
#251
04/28/2010 (7:33 am)
@Tony: I've just committed the Particle cloning fix :) I'm sending you an email about committing.
#252
04/28/2010 (2:15 pm)
I made a forum on the SVN site for bugs I found. Is there a better way to submit them? I am not familiar with the GIT hosting and such it just confuses me. If there is a bug tracking system I'll use it, just point me to it.
#253
04/28/2010 (2:28 pm)
The bug management system is in the tab "Project Tracking" ;)
#254
05/03/2010 (8:49 pm)
Welp, I must say you got me intrigued and I'd very much like to get the Torque X 2D patch from your svn, if you'd be so kind. Also, I find it extremely nice of each and everyone who collaborated in some way to help fix those issues or help new comers. Not particularly on topic, but it always make for a nice forum.

My e-mail is: olivier.giguere.durand [ /At\ ] reverseimpact.net

Thank you.
#255
05/14/2010 (3:58 pm)
I'd love to see what you guys have done with this, great job everyone. My email is bryan.k.clarke [at] gmail.com
#256
05/15/2010 (8:02 am)
Welcome to to club ;) Don't forget to go to the account settings and enable the email alerts to be aware of the changes ;)
#257
05/15/2010 (3:10 pm)
Hi Pino

I would love to see those SVN diff files, send an email to you.

Thank you.
#258
05/16/2010 (9:22 am)
Hey there Pino, all paid for. Having issues getting the base 360 game up and running and figured getting you SVN would be a better place to start. Hope to hear from you soon. Thanks!

- Chris
#259
05/16/2010 (9:41 am)
Hey Chris,

welcome on board :) Actually I guess the issue you are experimenting is about the Configuration Manager which is messed up in the templates. Having created the XBox 360 game copy open the Visual studio configuration manager and fix the mess: you'll see that there is a Win project on the Xbox platform and a Xbox project declared in the Win platform ;)

Next step will be to delete from the solution the Engine copy created in the working folder and then add the projects from the fixed engine (email is on its way) so to avoid this engine duplication thing which is quite odd ;)

Pino
#260
05/16/2010 (9:47 am)
BTW: Guys, during the fixing operations I found a minimalistic Finite State Machine in the engine core. I'm expanding it to something more useful. As the fixes are on the QA line (I suppose so reading Eric's posts) I'll add my modified FSM to the Community Project. This will be a cut & paste of Torque FSM plus my changes so future integrations will be easy to do.

Pino