NetEvent cleanup non-existant?
by Stefan Lundmark · in Torque Game Engine · 12/31/2006 (12:31 pm) · 4 replies
[Huh?]
Are NetEvents cleaned up in stock Torque when they have been used?
I can see a eventOnRemove (); function, but the memory is never freed, which means a few leaks here and there. Actually, one megabyte a minute if you continously send NetEvents.
Every time I minimize the window (it is a dedicated server) the memory footprint goes back down to what it was when started, and does not go back up when I maximize the window again. Wtf?
I'm aware of the Windows memory cache, could that be related?
[Progress]
OK, some code.
eventReadPacket ();
and
...gets rid of the constant memory increase, and all events fire off properly and our game still functions. Am I missing something here?
Happy new year!
Are NetEvents cleaned up in stock Torque when they have been used?
I can see a eventOnRemove (); function, but the memory is never freed, which means a few leaks here and there. Actually, one megabyte a minute if you continously send NetEvents.
Every time I minimize the window (it is a dedicated server) the memory footprint goes back down to what it was when started, and does not go back up when I maximize the window again. Wtf?
I'm aware of the Windows memory cache, could that be related?
[Progress]
OK, some code.
eventReadPacket ();
if(unguaranteedPhase)
{
evt->process(this);
evt->decRef();
[b]delete evt;[/b]and
while(mWaitSeqEvents && mWaitSeqEvents->mSeqCount == mNextRecvEventSeq)
{
mNextRecvEventSeq++;
NetEventNote *temp = mWaitSeqEvents;
mWaitSeqEvents = temp->mNextEvent;
temp->mEvent->process(this);
temp->mEvent->decRef();
mEventNoteChunker.free(temp);
[b]delete temp;[/b]...gets rid of the constant memory increase, and all events fire off properly and our game still functions. Am I missing something here?
Happy new year!
About the author
#2
I will continue to test this to see if I can produce any side-effects. Might be worth to mention that for the test I'm using the NetEvent class found in netTest.cpp.
Let's pretend that I keep the delete there together with the decref ();
Can I expect any serious issues with that or is it just ugly? :)
01/01/2007 (3:13 am)
Okay, I totally overlooked decRef ();I will continue to test this to see if I can produce any side-effects. Might be worth to mention that for the test I'm using the NetEvent class found in netTest.cpp.
Let's pretend that I keep the delete there together with the decref ();
Can I expect any serious issues with that or is it just ugly? :)
#3
01/01/2007 (3:30 am)
Yeah, you'll likely get double frees of memory. :)
#4
01/01/2007 (5:03 am)
Aha, which is why I should put an assert or something in there which checks the count? Right! Thanks.
Associate Kyle Carter
In theory decRef should delete the event. If you expect the count to be 1 (ie, will be deleted when decRef is called) then I'd add some asserts - it might only be certain events that are leaking.