Hello:
I have been dealing for some time with frustrating memory consumption in programs that use HTTPSecureSocket. To eliminate causes such as design flaws, unresolved circular references, etc., I have put together a primitive Console project (XOJO 2014, but should work in RealStudio 2012, too) to demonstrate the problem in simplest terms.
The project file is available from HERE . In short, this program’s output should demonstrate (at least on Windows, which is where I write and deploy my software) that HTTPSecureSockets operating with .secure=TRUE NEVER seem to have their Destructor() methods called when the instances should be considered out of scope. The result is an proliferation of detritus in the Runtime (as measured via Runtime.ObjectCount) and therefore memory “leakage”.
If I am “doing it wrong”, I would absolutely love to hear this – please tell me if you see that that is the case! I would be grateful to learn that there is some correct method that I am missing for releasing HTTPSecureSocket instances. However, I believe that the three scenarios in my test program belie that possibility.
Here’s a summary of what scenarios my XML project tests, when compiled/run, and what its results are (at least for me!):
-
TESTING METHOD:
a subclass is created for HTTPSocket, and one is also created for HTTPSecureSocket
the subclasses add only one thing: Destructor() methods that use StdOut.writeLine() to indicate that they are being called
a URL is synchronously pulled via GET three times in a row
Runtime.ObjectCount is checked before and after each iteration and then compared to see if there is a net increase or decrease in ObjectCount (where an increase would indicate a memory leak)
is the Destructor for the socket object called when it is finished its work, purged and closed, and then set to NIL?
-
TEST 1: HTTPSocket accessed the HTTP version of the URL 3 times in a row
RESULT: Destructor() methods ARE called, and there is no net increase in Runtime.ObjectCount with each iteration -
TEST 2: HTTPSecureSocket is used [with .secure=true and .connectionType=TLSv1] to access the HTTPS version of the same URL 3 times in a row
RESULT: Destructor() methods are NOT called, and there is a marked net increase (of 18) in Runtime.ObjectCount with each iteration -
TEST 3: HTTPSecureSocket is used [with .secure=false] to access the HTTP version of the same URL 3 times in a row
RESULT: Destructor() methods ARE called, and there is no net increase in Runtime.ObjectCount with each iteration (besides an increase in 1 with the first iteration)
Thoughts?