Scene Objects Go Black After a Period of Time [Answered]
by Josh Neider · in Torque X 2D · 02/22/2010 (6:29 pm) · 7 replies
We load up a scene and everything is going good but after anywhere from 15 seconds to 5 minutes objects in layers of the scene begin turning black beginning with the highest layer level (e.g. layer 30 will black out before layer 5).
I was thinking maybe a memory leak... however watching the process the memory sits at around 180MB and doesn't increase over that time. I'm also using the zoom feature which is a power based on how far the trigger is pulled in but only zooming up to 3x. I've noticed that when zoomed in the layers turn black more quickly.
Any ideas?
Thanks
Josh
I was thinking maybe a memory leak... however watching the process the memory sits at around 180MB and doesn't increase over that time. I'm also using the zoom feature which is a power based on how far the trigger is pulled in but only zooming up to 3x. I've noticed that when zoomed in the layers turn black more quickly.
Any ideas?
Thanks
Josh
#3
A memory leak is simply memory that is not getting released. In C# that includes anything the C# code is still referencing, but isn't actually needed anymore, and any non-managed resources that haven't been released, but should have been (e.g. graphics device resources that have not been disposed).
@Josh: Henry is right - in this instance it's not a leak - Henry's code should fix the issue for you.
02/23/2010 (10:44 am)
@Henry: unfortunately not getting memory leaks in managed code is an urban myth. What managed code stops you doing is referencing into memory badly and totally messing stuff up - it can't stop leaks.A memory leak is simply memory that is not getting released. In C# that includes anything the C# code is still referencing, but isn't actually needed anymore, and any non-managed resources that haven't been released, but should have been (e.g. graphics device resources that have not been disposed).
@Josh: Henry is right - in this instance it's not a leak - Henry's code should fix the issue for you.
#2
02/23/2010 (1:46 pm)
Awesome, thanks - I will give this a try tonight and report back.
#4
02/23/2010 (6:11 pm)
I think that overall coders just love to say memory leak it just sounds cool. ; )
#5
Ok, did I say memory leak enough?
02/23/2010 (7:53 pm)
You have a memory leak if your code has no way of releasing all references to your objects, so memory leaks are quite real in managed code. Memory leaks are often caused by static event handlers, but TX doesn't make any use of those I believe, so you wont get a memory leak that way.Ok, did I say memory leak enough?
#6
But the fix did work, thanks!!
02/24/2010 (7:55 am)
When I mentioned memory leak in the OP I was referring to bad coding in which I wasn't releasing/deleting objects after they were "used" - or when they left the scene (world limits). I figured watching the process memory would be a good way to judge whether or not I was doing something like that since I would have expected memory consumption to increase if I wasn't cleaning something up.But the fix did work, thanks!!
#7
02/25/2010 (3:31 am)
Just having fun man! I know I have done the same thing, once I forgot to give my projectiles world limits, and my enemy projectiles as well. That was fun...
Torque 3D Owner Henry Shilling
Smokin Skull
this is what you need to do:
T2DSceneCamera cam = TorqueObjectDatabase.Instance.FindObject<T2DSceneCamera>("Camera"); cam.FarDistance = 10000f;From this thread: www.torquepowered.com/community/forums/viewthread/81173
what you have is not a memory leak, you really cannot get a memory leak as C# is managed, we have no memory control really. What you probably do have is a lot of things on screen or you are not removing some things that should be.
Still I have to do this with almost every game I do.