I guarantee you that this code does not free up memory. I use it in my code here and you can put me read from socket to html page and you will see this error occur. I guarantee you with absolute certainty.
After I freed the memory before the return the problem stopped.
After a day running the memory doubled in size.
If I put this code there, just a socket that reads some simple html page is enough.