Game Development Community

Cleaning up HTTPObjects

by Igor G · in Torque Game Engine · 10/10/2008 (7:20 pm) · 4 replies

I have a lot of HTTPObjects sending requests to a server. I process the data in the onLine function, and when it's done, I don't need the object anymore. However, I don't see my HTTP objects disconnecting and cleaning up their memory. My web servers have threads devoted to HTTP requests, so it's up to the requester to close the connection. However, I don't think this is the case with HTTPObjects - it seems that HTTPObjects wait for the other side to close. What is the proper way to clean up my HTTPObjects? I've tried to schedule a delete after 10 seconds in my onLine functions, but after creating and using many HTTPObjects, my server seems to crash.

Thanks.

#1
10/10/2008 (7:35 pm)
Schedule a function that does .close .delete on your connection object.
#2
10/10/2008 (7:36 pm)
Try adding this code:

function HTTPObject::onDisconnect(%this)
{
	echo("Disconnecting HTTPObject");
	%this.delete();
}

I'm not 100% sure that stock TGE makes an onDisconnect script call. If you are not seeing that echo, you may need to all it in the source.

We are also setting a manual 30 second httpObject delete schedule. For some reason, onDisconnect isn't always called.
#3
10/11/2008 (12:38 am)
If you're making very heavy use of HTTP,
you migh consider integrating libCurl.
#4
10/15/2008 (6:49 am)
Thanks, I resolved this by using an external solution.