<div dir="ltr"><div><div>I build this simple TLS upgrading proxy[2], which sits in front of a TLS service and just accepts
connections using any SSL/TLS version that Racket supports and forwards
the data to the service using the default TLS version (why would I need this is a long story :)).<br></div><div><br></div>When
stress testing this using boom [1], I see significant memory buildup.
This memory is not released when the test finishes. It only gets
reclaimed when I kill the proxy process. So I suspect there is some
kind of memory leak going on here.<br><br></div>In principle, the only
values constructed on each iteration of the loop are the SSL connection
ports, which I'm closing when |pipe| exits.<div><br></div><div>Am I using copy-port wrong, or maybe it is itself leaking memory?<br><div><br></div><div>This is using Racket v6.1.1 on Ubuntu 14.10.</div><div><br>TIA!</div><div><br>[1] <a href="https://github.com/oxtoacart/boom">https://github.com/oxtoacart/boom</a></div><div><br><div><div>[2] Source:<br></div><div><br>#lang racket<br><br>(require openssl)<br><br>(define DEBUG #f)<br><br>(define (pipe in out)<br> (thread (λ ()<br> (if DEBUG<br> (copy-port in (current-output-port) out)<br> (copy-port in out))<br> (close-output-port out)<br> (close-input-port in))))<br><br>(define accept (if DEBUG ssl-accept/enable-break ssl-accept))<br>(define connect (if DEBUG ssl-connect/enable-break ssl-connect))<br><br>(define listener (ssl-listen 62445))<br>(ssl-load-private-key! listener "pk.pem")<br>(ssl-load-certificate-chain! listener "cert.pem")<br><br>(let loop ()<br> (let-values (((from-src to-src) (accept listener)))<br> (thread<br> (λ ()<br> (let-values (((from-dest to-dest)<br> (connect "localhost" 62444 'tls)))<br> (pipe from-src to-dest)<br> (pipe from-dest to-src)))))<br> (loop))<br></div></div></div></div></div>