My server program runs on windows(32bit) with Waitress + Pyramid.
When I tested an http API's performance with Apache ab, and the results data's size < 1M, i found the the memory keep increasing util Memory error thrown at last.
The ab command looks like below
ab -c 10 -n 100000 -k http://apiurl
The issue only happen in keep alive mode and data size is smaller than 1M.
After debug, I found the cause:
In keep alive mode, the http channel will not be closed in my test
When data size < 1M, channel will use memory file BytesIO as output buffer
In _flush_some function of channel.py, the output buffer will never be clear after all its data has been sent, see the code
# use outbuf.__len__ rather than len(outbuf) FBO of not getting# OverflowError on Python 2outbuflen=outbuf.__len__()
# self.outbufs[-1] must always be a writable outbufiflen(self.outbufs) >1:
'Unexpected error when closing an outbuf')
continue# pragma: no cover (coverage bug, it is hit)else:
# issue here, when outbuflen < 0, outbufs should be clear at leastdobreak=True
I added a line code in the marked place, then the issue could be workaround, please check if it is a reasonable fix:
The text was updated successfully, but these errors were encountered: